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.
3 4 5 |
# File 'lib/mirrored/tag.rb', line 3 def count @count end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mirrored/tag.rb', line 3 def name @name end |
Class Method Details
.find(*args) ⇒ Object
17 18 19 20 21 |
# File 'lib/mirrored/tag.rb', line 17 def 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:
6 7 8 9 10 11 |
# File 'lib/mirrored/tag.rb', line 6 def new_from_xml(xml) #:nodoc: t = Tag.new t.count = (xml)['count'] t.name = (xml)['tag'] t end |
.rename(old_name, new_name) ⇒ Object
27 28 29 30 31 |
# File 'lib/mirrored/tag.rb', line 27 def 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 |