Class: TwitterCldr::Resources::CldrDocumentSet::ElementList

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/twitter_cldr/resources/cldr_document_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docset, elements) ⇒ ElementList

Returns a new instance of ElementList.



39
40
41
42
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 39

def initialize(docset, elements)
  @docset = docset
  @elements = elements
end

Instance Attribute Details

#docsetObject (readonly)

Returns the value of attribute docset.



37
38
39
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 37

def docset
  @docset
end

#elementsObject (readonly)

Returns the value of attribute elements.



37
38
39
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 37

def elements
  @elements
end

Instance Method Details

#[](idx) ⇒ Object



44
45
46
47
48
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 44

def [](idx)
  return unless elements[idx]

  Element.new(docset, elements[idx])
end

#eachObject



54
55
56
57
58
59
60
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 54

def each
  return to_enum(__method__) unless block_given?

  elements.size.times do |idx|
    yield self[idx]
  end
end

#firstObject



50
51
52
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 50

def first
  self[0]
end