Class: Mirrored::Tag
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.find(*args) ⇒ Object
Does all the hard work finding your tags and how much you’ve used them.
-
.new_from_xml(xml) ⇒ Object
:nodoc:.
-
.rename(old_name, new_name) ⇒ Object
Renames a tag from the old name to a new one.
Methods inherited from Base
api_url, connection, establish_connection, remove_connection, service, valid_service?
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
30 31 32 |
# File 'lib/mirrored/tag.rb', line 30 def count @count end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'lib/mirrored/tag.rb', line 30 def name @name end |
Class Method Details
.find(*args) ⇒ Object
14 15 16 17 18 |
# File 'lib/mirrored/tag.rb', line 14 def self.find(*args) raise ArgumentError, "Only takes a symbol as the argument (:get, :all)" unless args.first.kind_of?(Symbol) doc = Hpricot::XML(connection.get('tags/get')) (doc/:tag).inject([]) { |elements, el| elements << Tag.new_from_xml(el); elements } end |
.new_from_xml(xml) ⇒ Object
:nodoc:
3 4 5 6 7 8 |
# File 'lib/mirrored/tag.rb', line 3 def self.new_from_xml(xml) #:nodoc: t = Tag.new t.count = (xml)['count'] t.name = (xml)['tag'] t end |
.rename(old_name, new_name) ⇒ Object
24 25 26 27 28 |
# File 'lib/mirrored/tag.rb', line 24 def self.rename(old_name, new_name) doc = Hpricot::XML(connection.get('tags/rename', :old => old_name, :new => new_name)) result = (doc).at(:result) (result && result.inner_html == 'done') ? true : false end |