Class: Rets::Metadata::Containers::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/rets/metadata/containers.rb

Direct Known Subclasses

RowContainer, SystemContainer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fragment) ⇒ Container

Returns a new instance of Container.



25
26
27
# File 'lib/rets/metadata/containers.rb', line 25

def initialize(fragment)
  self.fragment = fragment
end

Instance Attribute Details

#fragmentObject

Returns the value of attribute fragment.



12
13
14
# File 'lib/rets/metadata/containers.rb', line 12

def fragment
  @fragment
end

Class Method Details

.uses(*fields) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/rets/metadata/containers.rb', line 14

def self.uses(*fields)
  fields.each do |field|
    define_method(field) do
      instance_variable_get("@#{field}") ||
        instance_variable_set("@#{field}", extract(fragment, field.to_s.capitalize))
    end
  end
end

Instance Method Details

#extract(fragment, attr) ⇒ Object



29
30
31
# File 'lib/rets/metadata/containers.rb', line 29

def extract(fragment, attr)
  fragment.attr(attr)
end