Class: Itinerary::View

Inherits:
Object
  • Object
show all
Defined in:
lib/itinerary/view.rb,
lib/itinerary/views/kml.rb,
lib/itinerary/views/tab.rb,
lib/itinerary/views/html.rb,
lib/itinerary/views/text.rb

Direct Known Subclasses

HTML, KML, Tab, Text

Defined Under Namespace

Classes: HTML, KML, Tab, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(itinerary, params = {}) ⇒ View

Returns a new instance of View.



8
9
10
11
12
13
14
# File 'lib/itinerary/view.rb', line 8

def initialize(itinerary, params={})
  @itinerary = itinerary
  @show_fields = Record.field_keys
  @hide_fields = []
  @output = StringIO.new
  params.each { |k, v| method("#{k}=").call(v) }
end

Instance Attribute Details

#hide_fieldsObject

Returns the value of attribute hide_fields.



6
7
8
# File 'lib/itinerary/view.rb', line 6

def hide_fields
  @hide_fields
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/itinerary/view.rb', line 4

def name
  @name
end

#show_fieldsObject

Returns the value of attribute show_fields.



5
6
7
# File 'lib/itinerary/view.rb', line 5

def show_fields
  @show_fields
end

Instance Method Details

#render(entries) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/itinerary/view.rb', line 16

def render(entries)
  @field_keys = @show_fields - @hide_fields
  entries.each do |rec|
    render_record(rec)
  end
  @output.rewind
  @output.read
end