Class: API::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/quintype/api/tag.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag) ⇒ Tag

Returns a new instance of Tag.



26
27
28
# File 'lib/quintype/api/tag.rb', line 26

def initialize(tag)
  @tag = tag
end

Instance Attribute Details

#tagObject (readonly)

Returns the value of attribute tag.



5
6
7
# File 'lib/quintype/api/tag.rb', line 5

def tag
  @tag
end

Class Method Details

.find_by_name(name) ⇒ Object



19
20
21
22
23
# File 'lib/quintype/api/tag.rb', line 19

def find_by_name(name)
  if tag = API.tag_by_name(URI.encode(name))
    wrap(tag)
  end
end

.wrap(tag) ⇒ Object



15
16
17
# File 'lib/quintype/api/tag.rb', line 15

def wrap(tag)
  new(tag) if tag
end

.wrap_all(tags) ⇒ Object



8
9
10
11
12
13
# File 'lib/quintype/api/tag.rb', line 8

def wrap_all(tags)
  tags ||= []
  tags.is_a?(Array) ?
    tags.map {|t| wrap(t)} :
    wrap(tags)
end

Instance Method Details

#to_h(config = {}) ⇒ Object



30
31
32
# File 'lib/quintype/api/tag.rb', line 30

def to_h(config={})
  self.tag["tag"]
end