Class: INatGet::Data::DSL::Report::ERB

Inherits:
INatGet::Data::DSL::Report show all
Defined in:
lib/inat-get/data/dsl/reports/erb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


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

#dataHash (readonly)

Returns:

  • (Hash)


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

Returns:

  • (String)


25
26
27
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 25

def ext mode: nil
  @ext
end

#renderString

Returns:

  • (String)


30
31
32
# File 'lib/inat-get/data/dsl/reports/erb.rb', line 30

def render
  @erb.result binding
end