Module: Dustbag::Parser::Node
- Extended by:
- Forwardable
- Included in:
- Accessory, AvailabilityAttributes, BrowseNode, Common, CustomerReviews, Dimension, Dimensions, EditorialReview, Image, ImageSet, Item, ItemAttributes, ItemLink, ItemSearchRequest, ItemSearchResponse, Items, Language, Offer, OfferSummary, OperationRequest, CollectionNode, Request, SimilarProduct, SimpleProduct, VariationAttribute, VariationSummary, Variations
- Defined in:
- lib/dustbag/parser/node.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#subnodes ⇒ Object
readonly
Returns the value of attribute subnodes.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(node) ⇒ Object
- #repeated_subnodes(subnode_name) ⇒ Object
- #repeated_subnodes_text(subnode_name) ⇒ Object
- #subnode(subnode_name) ⇒ Object
- #subnode_text(subnode_name) ⇒ Object
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/dustbag/parser/node.rb', line 4 def node @node end |
#subnodes ⇒ Object (readonly)
Returns the value of attribute subnodes.
4 5 6 |
# File 'lib/dustbag/parser/node.rb', line 4 def subnodes @subnodes end |
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/dustbag/parser/node.rb', line 9 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize(node) ⇒ Object
13 14 15 16 |
# File 'lib/dustbag/parser/node.rb', line 13 def initialize(node) @node = node @subnodes = {} end |
#repeated_subnodes(subnode_name) ⇒ Object
27 28 29 |
# File 'lib/dustbag/parser/node.rb', line 27 def repeated_subnodes(subnode_name) subnodes[subnode_name] ||= node.locate(subnode_name) end |
#repeated_subnodes_text(subnode_name) ⇒ Object
31 32 33 |
# File 'lib/dustbag/parser/node.rb', line 31 def repeated_subnodes_text(subnode_name) repeated_subnodes(subnode_name).map(&:text) end |
#subnode(subnode_name) ⇒ Object
23 24 25 |
# File 'lib/dustbag/parser/node.rb', line 23 def subnode(subnode_name) subnodes[subnode_name] ||= node.locate(subnode_name).first end |
#subnode_text(subnode_name) ⇒ Object
18 19 20 21 |
# File 'lib/dustbag/parser/node.rb', line 18 def subnode_text(subnode_name) subnode = subnode(subnode_name) subnode && subnode.text end |