Class: WWW::Delicious::Tag
- Inherits:
-
Object
- Object
- WWW::Delicious::Tag
- Defined in:
- lib/www/delicious/tag.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
The number of links tagged with this tag.
-
#name ⇒ Object
The name of the tag.
Instance Method Summary collapse
-
#api_valid? ⇒ Boolean
Returns wheter this object is valid for an API request.
-
#initialize(values_or_rexml) {|_self| ... } ⇒ Tag
constructor
Creates a new
WWW::Delicious::Tag
. -
#initialize_from_hash(values) ⇒ Object
Initializes
WWW::Delicious::Tag
from an Hash. -
#initialize_from_rexml(element) ⇒ Object
Initializes
WWW::Delicious::Tag
from a REXML fragment. -
#to_s ⇒ Object
Returns a string representation of this Tag.
Constructor Details
#initialize(values_or_rexml) {|_self| ... } ⇒ Tag
Creates a new WWW::Delicious::Tag
.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/www/delicious/tag.rb', line 34 def initialize(values_or_rexml, &block) # :yields: tag case values_or_rexml when Hash initialize_from_hash(values_or_rexml) when REXML::Element initialize_from_rexml(values_or_rexml) else raise ArgumentError, 'Expected `values_or_rexml` to be `Hash` or `REXML::Element`' end yield(self) if block_given? self end |
Instance Attribute Details
#count ⇒ Object
The number of links tagged with this tag. It should be set only from an API response.
27 28 29 |
# File 'lib/www/delicious/tag.rb', line 27 def count @count end |
#name ⇒ Object
The name of the tag
23 24 25 |
# File 'lib/www/delicious/tag.rb', line 23 def name @name end |
Instance Method Details
#api_valid? ⇒ Boolean
113 114 115 |
# File 'lib/www/delicious/tag.rb', line 113 def api_valid? return !name.empty? end |
#initialize_from_hash(values) ⇒ Object
Initializes WWW::Delicious::Tag
from an Hash.
61 62 63 64 |
# File 'lib/www/delicious/tag.rb', line 61 def initialize_from_hash(values) self.name = values[:name] self.count = values[:count] end |
#initialize_from_rexml(element) ⇒ Object
Initializes WWW::Delicious::Tag
from a REXML fragment.
52 53 54 55 |
# File 'lib/www/delicious/tag.rb', line 52 def initialize_from_rexml(element) self.name = element.attribute_value(:tag) self.count = element.attribute_value(:count) end |
#to_s ⇒ Object
Returns a string representation of this Tag.
91 92 93 |
# File 'lib/www/delicious/tag.rb', line 91 def to_s() return self.name end |