Class: TwitterCldr::Resources::CldrDTD::Attr
- Inherits:
-
Object
- Object
- TwitterCldr::Resources::CldrDTD::Attr
- Defined in:
- lib/twitter_cldr/resources/cldr_dtd.rb
Instance Attribute Summary collapse
-
#dtd ⇒ Object
readonly
Returns the value of attribute dtd.
-
#element_name ⇒ Object
readonly
Returns the value of attribute element_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, element_name, dtd) ⇒ Attr
constructor
A new instance of Attr.
- #values ⇒ Object
Constructor Details
#initialize(name, element_name, dtd) ⇒ Attr
Returns a new instance of Attr.
13 14 15 16 17 |
# File 'lib/twitter_cldr/resources/cldr_dtd.rb', line 13 def initialize(name, element_name, dtd) @name = name @element_name = element_name @dtd = dtd end |
Instance Attribute Details
#dtd ⇒ Object (readonly)
Returns the value of attribute dtd.
11 12 13 |
# File 'lib/twitter_cldr/resources/cldr_dtd.rb', line 11 def dtd @dtd end |
#element_name ⇒ Object (readonly)
Returns the value of attribute element_name.
11 12 13 |
# File 'lib/twitter_cldr/resources/cldr_dtd.rb', line 11 def element_name @element_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/twitter_cldr/resources/cldr_dtd.rb', line 11 def name @name end |
Instance Method Details
#values ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/twitter_cldr/resources/cldr_dtd.rb', line 19 def values @values ||= begin attr_line_idx = schema.find_index do |line| line.include?("<!ATTLIST #{element_name} #{name} ") end return [] unless attr_line_idx attr_line = schema[attr_line_idx] if comment = find_match_comment_after(attr_line_idx + 1) parse_match(comment) else start_idx = attr_line.index('(') return [] unless start_idx finish_idx = attr_line.rindex(')') attr_line[(start_idx + 1)...finish_idx].split('|').map(&:strip) end end end |