Class: OpenGraphy::TagNamespace
- Inherits:
-
Object
- Object
- OpenGraphy::TagNamespace
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/open_graphy/tag_namespace.rb
Instance Method Summary collapse
- #add_to(key, value, tag) ⇒ Object
- #any? ⇒ Boolean
- #child_name ⇒ Object
-
#initialize(namespace = []) ⇒ TagNamespace
constructor
A new instance of TagNamespace.
- #next ⇒ Object
Constructor Details
#initialize(namespace = []) ⇒ TagNamespace
Returns a new instance of TagNamespace.
8 9 10 |
# File 'lib/open_graphy/tag_namespace.rb', line 8 def initialize(namespace=[]) @namespace = namespace end |
Instance Method Details
#add_to(key, value, tag) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/open_graphy/tag_namespace.rb', line 16 def add_to(key, value, tag) if any? tag.define_namespace(child_name).add(key, value, namespace: self.next) else tag.define_value(key, value) end end |
#any? ⇒ Boolean
12 13 14 |
# File 'lib/open_graphy/tag_namespace.rb', line 12 def any? namespace.any? && first != 'og' end |
#child_name ⇒ Object
24 25 26 |
# File 'lib/open_graphy/tag_namespace.rb', line 24 def child_name namespace.first end |
#next ⇒ Object
28 29 30 31 32 |
# File 'lib/open_graphy/tag_namespace.rb', line 28 def next TagNamespace.new( [namespace.size > 1 ? namespace.last : nil].compact ) end |