Class: Hindbaer::Marker

Inherits:
Object
  • Object
show all
Defined in:
lib/hindbaer/marker.rb

Constant Summary collapse

ATTRIBUTES =
%w{
  id name time
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Marker

Returns a new instance of Marker.



21
22
23
# File 'lib/hindbaer/marker.rb', line 21

def initialize(&block)
  block.arity > 0 ? block.call(self) : instance_eval(&block)
end

Class Method Details

.parse(fragment) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/hindbaer/marker.rb', line 10

def self.parse(fragment)
  new do
    ATTRIBUTES.each do |attribute|
      self.send(
        "#{attribute.to_sym}=",   
        fragment[attribute.split('_').map(&:capitalize).join]
      )
    end
  end
end

Instance Method Details

#to_xml(xml) ⇒ Object



25
26
27
# File 'lib/hindbaer/marker.rb', line 25

def to_xml(xml)
  xml.Marker Id: id, Name: name, Time: time
end