Class: MITS::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/mits/document.rb

Constant Summary collapse

DEFAULT_VERSION =
'4.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) ⇒ Document

Returns a new instance of Document.



7
8
9
10
11
12
13
# File 'lib/mits/document.rb', line 7

def initialize(url, opts = {})
  @version = (opts[:version] || DEFAULT_VERSION).to_s
  @parser  = ::Saxerator.parser(open(url)) do |c|
    c.put_attributes_in_hash!
    c.symbolize_keys!
  end
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



3
4
5
# File 'lib/mits/document.rb', line 3

def parser
  @parser
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/mits/document.rb', line 3

def version
  @version
end

Instance Method Details

#companiesObject



23
24
25
26
27
28
29
# File 'lib/mits/document.rb', line 23

def companies
  return enum_for(:companies) unless block_given?

  physical_property.within(:Management).within(:PropertyContacts).each do |tag|
    yield mapper.company(tag, company_entity)
  end
end

#propertiesObject



15
16
17
18
19
20
21
# File 'lib/mits/document.rb', line 15

def properties
  return enum_for(:properties) unless block_given?

  physical_property.for_tag(:Property).each do |tag|
    yield mapper.property(tag)
  end
end