Class: WWW::Delicious::Tag
Overview
Delicious Tag
Represents a single Tag element.
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns value for
count
attribute. -
#name ⇒ Object
Returns value for
name
attribute.
Class Method Summary collapse
-
.from_rexml(element) ⇒ Object
Creates and returns new instance from a REXML
element
.
Instance Method Summary collapse
-
#api_valid? ⇒ Boolean
Returns whether this object is valid for an API request.
-
#to_s ⇒ Object
Returns a string representation of this Tag.
Methods inherited from Element
Constructor Details
This class inherits a constructor from WWW::Delicious::Element
Instance Attribute Details
#count ⇒ Object
Returns value for count
attribute. Value is always normalized to Fixnum.
35 36 37 |
# File 'lib/www/delicious/tag.rb', line 35 def count @count end |
#name ⇒ Object
Returns value for name
attribute. Value is always normalized as lower string.
31 32 33 |
# File 'lib/www/delicious/tag.rb', line 31 def name @name end |
Class Method Details
.from_rexml(element) ⇒ Object
Creates and returns new instance from a REXML element
.
Implements Element#from_rexml.
87 88 89 90 91 92 93 |
# File 'lib/www/delicious/tag.rb', line 87 def from_rexml(element) raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element self.new do |instance| instance.name = element.if_attribute_value(:tag) instance.count = element.if_attribute_value(:count) { |value| value.to_i } end end |
Instance Method Details
#api_valid? ⇒ Boolean
75 76 77 |
# File 'lib/www/delicious/tag.rb', line 75 def api_valid? return !name.empty? end |
#to_s ⇒ Object
Returns a string representation of this Tag. In case name is nil this method will return an empty string.
54 55 56 |
# File 'lib/www/delicious/tag.rb', line 54 def to_s name.to_s end |