Class: Inforouter::PropertyRow

Inherits:
Record
  • Object
show all
Defined in:
lib/inforouter/property_row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ PropertyRow

Returns a new instance of PropertyRow.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/inforouter/property_row.rb', line 9

def initialize(params = {})
  # Declare instance variables from params hash.
  params.each do |k, v|
    # Remove leading at.
    k = k.to_s.sub(/^@/, '')
    instance_variable_set("@#{k}", v)
    eigenclass = class << self; self; end
    eigenclass.class_eval do
      attr_accessor k
    end
  end
end

Instance Attribute Details

#row_nbrObject Also known as: row_number

Property row index.



4
5
6
# File 'lib/inforouter/property_row.rb', line 4

def row_nbr
  @row_nbr
end

Instance Method Details

#to_xml(xml) ⇒ Nokogiri::XML::Builder::NodeBuilder

Parameters:

  • xml (Nokogiri::XML::Builder)

Returns:

  • (Nokogiri::XML::Builder::NodeBuilder)


25
26
27
28
29
30
31
32
33
# File 'lib/inforouter/property_row.rb', line 25

def to_xml(xml)
  fields = {}
  instance_variables.each do |ivar|
    name = ivar.to_s.sub(/^@/, '')
    name == 'row_nbr' ? name = 'RowNbr' : name.upcase!
    fields[name] = instance_variable_get(ivar)
  end
  xml.propertyrow fields unless fields.empty?
end