Class: Fappu::Tag

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

Constant Summary collapse

URL =
"https://api.fakku.net/tags"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Tag

Returns a new instance of Tag.



7
8
9
10
11
# File 'lib/fappu/tag.rb', line 7

def initialize args
  args.each do |k,v|
    instance_variable_set("@#{k}",v) unless v.nil?
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/fappu/tag.rb', line 4

def name
  @name
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/fappu/tag.rb', line 4

def url
  @url
end

Class Method Details

.listObject



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

def self.list
  response = JSON.parse( URI.parse(URL).read )
  arr = response["tags"]

  arr.collect do |tag|
    self.new(tag_parameters(tag))
  end
end