Class: Thingiverse::Tags

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/thingiverse/tags.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Tags

Returns a new instance of Tags.



7
8
9
10
11
# File 'lib/thingiverse/tags.rb', line 7

def initialize(attributes={})
  attributes.each do |name, value|
    send("#{name}=", value)
  end
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



6
7
8
# File 'lib/thingiverse/tags.rb', line 6

def count
  @count
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/thingiverse/tags.rb', line 6

def name
  @name
end

#things_urlObject

Returns the value of attribute things_url.



6
7
8
# File 'lib/thingiverse/tags.rb', line 6

def things_url
  @things_url
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/thingiverse/tags.rb', line 6

def url
  @url
end

Class Method Details

.find(tag_name) ⇒ Object



22
23
24
25
26
# File 'lib/thingiverse/tags.rb', line 22

def self.find(tag_name)
  response = Thingiverse::Connection.get("/tags/#{tag_name}")
  raise "#{response.code}: #{JSON.parse(response.body)['error']}" unless response.success?
  self.new response.parsed_response
end

Instance Method Details

#attributesObject



13
14
15
16
17
18
19
20
# File 'lib/thingiverse/tags.rb', line 13

def attributes
  {
    :name => name,
    :url => url,
    :count => count,
    :things_url => things_url
  }
end

#things(query = {}) ⇒ Object



28
29
30
# File 'lib/thingiverse/tags.rb', line 28

def things(query = {})
  Thingiverse::Pagination.new(Thingiverse::Connection.get(things_url, :query => query), Thingiverse::Things)
end