Class: NationalDay

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_detailsObject (readonly)

Returns the value of attribute has_details.



3
4
5
# File 'lib/nationalday.rb', line 3

def has_details
  @has_details
end

#imageObject

Returns the value of attribute image.



2
3
4
# File 'lib/nationalday.rb', line 2

def image
  @image
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/nationalday.rb', line 2

def name
  @name
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/nationalday.rb', line 2

def summary
  @summary
end

#urlObject

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