Class: TwitterCldr::Resources::CldrDocumentSet
- Inherits:
-
Object
- Object
- TwitterCldr::Resources::CldrDocumentSet
- Defined in:
- lib/twitter_cldr/resources/cldr_document_set.rb
Defined Under Namespace
Classes: Element, ElementList
Instance Attribute Summary collapse
-
#cldr_locale ⇒ Object
readonly
Returns the value of attribute cldr_locale.
-
#cldr_requirement ⇒ Object
readonly
Returns the value of attribute cldr_requirement.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, cldr_locale, cldr_requirement) ⇒ CldrDocumentSet
constructor
A new instance of CldrDocumentSet.
- #path_for(node) ⇒ Object
- #xpath(path) ⇒ Object
Constructor Details
#initialize(path, cldr_locale, cldr_requirement) ⇒ CldrDocumentSet
Returns a new instance of CldrDocumentSet.
70 71 72 73 74 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 70 def initialize(path, cldr_locale, cldr_requirement) @path = path @cldr_locale = cldr_locale @cldr_requirement = cldr_requirement end |
Instance Attribute Details
#cldr_locale ⇒ Object (readonly)
Returns the value of attribute cldr_locale.
68 69 70 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 68 def cldr_locale @cldr_locale end |
#cldr_requirement ⇒ Object (readonly)
Returns the value of attribute cldr_requirement.
68 69 70 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 68 def cldr_requirement @cldr_requirement end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
68 69 70 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 68 def path @path end |
Class Method Details
.join_xpaths(*paths) ⇒ Object
64 65 66 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 64 def self.join_xpaths(*paths) paths.map { |a| a.chomp('/') }.join('/') end |
Instance Method Details
#path_for(node) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 89 def path_for(node) orig_node = node path = [] while node path << selector_for(node) node = node.parent break if node.name == 'document' end "//#{path.reverse.join('/')}" end |
#xpath(path) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/twitter_cldr/resources/cldr_document_set.rb', line 77 def xpath(path) cldr_locale.ancestors.each do |ancestor_locale| data = doc_for(ancestor_locale).xpath(path) unless data.empty? return ElementList.new(self, resolve_aliases_in(data)) end end ElementList.new(self, []) end |