Class: ApprovalRatings::Rating

Inherits:
Object
  • Object
show all
Defined in:
lib/approval_ratings/rating.rb

Overview

OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, date = nil, summary = nil, approval = nil, disapproval = nil) ⇒ Rating

Returns a new instance of Rating.



9
10
11
12
13
14
15
16
# File 'lib/approval_ratings/rating.rb', line 9

def initialize(name = nil, date = nil, summary = nil, approval = nil, disapproval = nil)
  @name = name
  @date = date
  @summary = summary
  @approval = approval
  @disapproval = disapproval
  @url = 'https://projects.fivethirtyeight.com/trump-approval-ratings/'
end

Instance Attribute Details

#approvalObject

Returns the value of attribute approval.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def approval
  @approval
end

#dateObject

Returns the value of attribute date.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def date
  @date
end

#disapprovalObject

Returns the value of attribute disapproval.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def disapproval
  @disapproval
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def name
  @name
end

#summaryObject

Returns the value of attribute summary.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def summary
  @summary
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/approval_ratings/rating.rb', line 7

def url
  @url
end

Class Method Details

.allObject



18
19
20
# File 'lib/approval_ratings/rating.rb', line 18

def self.all
  @@all ||= scrape_approval_ratings
end

.find(id) ⇒ Object



22
23
24
# File 'lib/approval_ratings/rating.rb', line 22

def self.find(id)
  self.all[id-1]
end

.find_by_name(name) ⇒ Object



26
27
28
# File 'lib/approval_ratings/rating.rb', line 26

def self.find_by_name(name)
  self.all.find_all { |i|  i.name.downcase.strip == name.downcase.strip }  
end