Class: Greeve::Namespace
- Inherits:
-
Object
- Object
- Greeve::Namespace
- Defined in:
- lib/greeve/namespace.rb
Overview
Contains a group of attributes.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
Name of the namespace.
Instance Method Summary collapse
-
#initialize(name, xml_element) { ... } ⇒ Namespace
constructor
A new instance of Namespace.
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ String
A string representation of the non-nil attributes.
Methods included from Helpers::AttributeToHash
Constructor Details
#initialize(name, xml_element) { ... } ⇒ Namespace
Returns a new instance of Namespace
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/greeve/namespace.rb', line 18 def initialize(name, xml_element, &block) @name = name @xml_element = xml_element @attributes = {} # Load the attribute configuration in the rowset block. instance_eval(&block) # Disable the DSL methods since the attributes have been configured. define_singleton_method(:attribute) { raise NoMethodError, "private method" } define_singleton_method(:namespace) { raise NoMethodError, "private method" } end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns name of the namespace
13 14 15 |
# File 'lib/greeve/namespace.rb', line 13 def name @name end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
32 33 34 35 36 |
# File 'lib/greeve/namespace.rb', line 32 def inspect attrs = to_s.lines[1..-1].join "#<#{self.class.name}:#{object_id} name: #{@name}\n#{attrs}\n>" end |
#to_s ⇒ String
Returns a string representation of the non-nil attributes
39 40 41 42 43 44 45 46 47 |
# File 'lib/greeve/namespace.rb', line 39 def to_s "#{@name}\n" + to_h .map { |k, v| v = v.to_s("F") if v.is_a?(BigDecimal) " #{k}: #{v}" } .join("\n") end |