Class: NationalDay
- Inherits:
-
Object
- Object
- NationalDay
- Defined in:
- lib/nationalday.rb
Instance Attribute Summary collapse
-
#has_details ⇒ Object
readonly
Returns the value of attribute has_details.
-
#image ⇒ Object
Returns the value of attribute image.
-
#name ⇒ Object
Returns the value of attribute name.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#add_details(hash = Scraper.scrape_day_details(url)) ⇒ Object
add details from the provided has, if no hash is provided details with automatically be pulled from the url Checkl to see if #has_details is true to avoid excess network requests.
-
#initialize(hash) ⇒ NationalDay
constructor
A new instance of NationalDay.
Constructor Details
#initialize(hash) ⇒ NationalDay
Returns a new instance of NationalDay.
4 5 6 7 8 9 |
# File 'lib/nationalday.rb', line 4 def initialize(hash) hash.each do |k,v| self.send("#{k}=",v) end @has_details=false end |
Instance Attribute Details
#has_details ⇒ Object (readonly)
Returns the value of attribute has_details.
3 4 5 |
# File 'lib/nationalday.rb', line 3 def has_details @has_details end |
#image ⇒ Object
Returns the value of attribute image.
2 3 4 |
# File 'lib/nationalday.rb', line 2 def image @image end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/nationalday.rb', line 2 def name @name end |
#summary ⇒ Object
Returns the value of attribute summary.
2 3 4 |
# File 'lib/nationalday.rb', line 2 def summary @summary end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/nationalday.rb', line 2 def url @url end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/nationalday.rb', line 21 def ==(other) name==other.name&&url==other.url&&summary==other.summary&&image==other.image end |
#add_details(hash = Scraper.scrape_day_details(url)) ⇒ Object
add details from the provided has, if no hash is provided details with automatically be pulled from the url Checkl to see if #has_details is true to avoid excess network requests
13 14 15 16 17 18 19 |
# File 'lib/nationalday.rb', line 13 def add_details(hash=Scraper.scrape_day_details(url)) hash.each do |k,v| #tfw you cant check to see if a method is defined with a string, only a symbol self.send("#{k}=",v) end @has_details=true end |