Class: Tesco::Groceries::Offer
- Inherits:
-
Object
- Object
- Tesco::Groceries::Offer
- Defined in:
- lib/tesco.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#valid_from ⇒ Object
readonly
Returns the value of attribute valid_from.
-
#valid_until ⇒ Object
readonly
Returns the value of attribute valid_until.
-
#validity ⇒ Object
readonly
Returns the value of attribute validity.
Instance Method Summary collapse
-
#initialize(image_url, descr, validity) ⇒ Offer
constructor
No point in making these by hand!.
Constructor Details
#initialize(image_url, descr, validity) ⇒ Offer
No point in making these by hand!
538 539 540 541 542 543 544 |
# File 'lib/tesco.rb', line 538 def initialize(image_url,descr,validity) # :nodoc: raise ArgumentError, "Not a valid offer" if descr.nil? or descr.empty? @description = descr @image_url = image_url @validity = validity @valid_from, @valid_until = Time.utc($3,$2,$1), Time.utc($6,$5,$4) if validity =~ /^valid from (\d{1,2})\/(\d{1,2})\/(\d{4}) until (\d{1,2})\/(\d{1,2})\/(\d{4})$/ end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
534 535 536 |
# File 'lib/tesco.rb', line 534 def description @description end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
534 535 536 |
# File 'lib/tesco.rb', line 534 def image_url @image_url end |
#valid_from ⇒ Object (readonly)
Returns the value of attribute valid_from.
535 536 537 |
# File 'lib/tesco.rb', line 535 def valid_from @valid_from end |
#valid_until ⇒ Object (readonly)
Returns the value of attribute valid_until.
535 536 537 |
# File 'lib/tesco.rb', line 535 def valid_until @valid_until end |
#validity ⇒ Object (readonly)
Returns the value of attribute validity.
534 535 536 |
# File 'lib/tesco.rb', line 534 def validity @validity end |