Class: Theysaidso::QOD

Inherits:
Object
  • Object
show all
Defined in:
lib/theysaidso/qod.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ QOD

Returns a new instance of QOD.



9
10
11
12
13
14
15
16
17
# File 'lib/theysaidso/qod.rb', line 9

def initialize(attrs)
  @id       = attrs['contents']['id']
  @quote    = attrs['contents']['quote']
  @author   = attrs['contents']['author']
  @length   = attrs['contents']['length']
  @tags     = attrs['contents']['tags']
  @success  = attrs['success']['total']
  @category = attrs['category']
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def author
  @author
end

#categoryObject (readonly)

Returns the value of attribute category.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def category
  @category
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def id
  @id
end

#lengthObject (readonly)

Returns the value of attribute length.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def length
  @length
end

#quoteObject (readonly)

Returns the value of attribute quote.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def quote
  @quote
end

#successObject (readonly)

Returns the value of attribute success.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def success
  @success
end

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/theysaidso/qod.rb', line 7

def tags
  @tags
end

Class Method Details

.fetchObject



19
20
21
22
23
# File 'lib/theysaidso/qod.rb', line 19

def self.fetch
  response = Faraday.get(API_URL)
  attrs = JSON.parse(response.body)
  new(attrs)
end