Class: INatGet::Data::DSL::Report::ERB
- Inherits:
-
INatGet::Data::DSL::Report
- Object
- INatGet::Data::DSL::Report
- INatGet::Data::DSL::Report::ERB
- Defined in:
- lib/inat-get/data/dsl/reports/erb.rb
Instance Attribute Summary collapse
- #data ⇒ Hash readonly
Instance Method Summary collapse
- #ext(mode: nil) ⇒ String
-
#initialize(code = nil, file: nil, ext: nil, trim_mode: nil, suffix: nil, **data, &block) ⇒ ERB
constructor
A new instance of ERB.
- #render ⇒ String
Methods inherited from INatGet::Data::DSL::Report
#[], #[]=, #basename, #filename, #save
Methods included from INatGet::Data::DSL
#AND, #ANYTHING, #NOT, #NOTHING, #OR, #Q, #console, #erb_report, #finish_time, #get_identification, #get_observation, #get_place, #get_project, #get_taxon, #get_user, #now, #select_identifications, #select_observations, #select_places, #select_projects, #select_taxa, #select_users, #start_time, #time_range, #today, #version, #version!, #version?, #version_alias
Constructor Details
#initialize(code = nil, file: nil, ext: nil, trim_mode: nil, suffix: nil, **data, &block) ⇒ ERB
Returns a new instance of ERB.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 9 def initialize code = nil, file: nil, ext: nil, trim_mode: nil, suffix: nil, **data, &block @code = code @code ||= File.read(file) if file raise ArgumentError, "Source not specified", caller_locations unless @code @ext = ext @ext ||= File.extname(File.basename(file, '.erb')) if file @erb = ::ERB::new @code, trim_mode: trim_mode @erb.filename = file || '(erb)' suffix ||= File.basename(File.basename(file, '.erb'), '.*') if file super(mode: nil, suffix: suffix, **data, &block) end |
Instance Attribute Details
#data ⇒ Hash (readonly)
22 23 24 |
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 22 def data @data end |
Instance Method Details
#ext(mode: nil) ⇒ String
25 26 27 |
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 25 def ext mode: nil @ext end |
#render ⇒ String
30 31 32 |
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 30 def render @erb.result binding end |