Class: Greeve::Row
- Inherits:
-
Object
- Object
- Greeve::Row
- Defined in:
- lib/greeve/row.rb
Overview
Represents an XML ‘row` element, contained in a Rowset.
Instance Method Summary collapse
-
#initialize(xml_element, attributes) ⇒ Row
constructor
A new instance of Row.
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ String
A string representation of the non-nil attributes.
Methods included from Helpers::AttributeToHash
Constructor Details
#initialize(xml_element, attributes) ⇒ Row
Returns a new instance of Row.
12 13 14 15 16 17 18 19 |
# File 'lib/greeve/row.rb', line 12 def initialize(xml_element, attributes) @xml_element = xml_element @attributes = attributes attributes.each do |name, opts| define_attribute_method(:instance, name, opts) end end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/greeve/row.rb', line 22 def inspect attrs = to_s unless attrs.empty? attrs = attrs.split("\n").map { |l| " #{l}" }.join("\n") attrs = "\n#{attrs}\n" end "#<#{self.class.name}:#{object_id}#{attrs}>" end |
#to_s ⇒ String
Returns a string representation of the non-nil attributes.
34 35 36 37 38 39 40 41 |
# File 'lib/greeve/row.rb', line 34 def to_s to_h .map { |k, v| v = v.to_s("F") if v.is_a?(BigDecimal) "#{k}: #{v}" } .join("\n") end |