Class: Tesco::Groceries::Offer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_url, descr, validity) ⇒ Offer

No point in making these by hand!

Raises:

  • (ArgumentError)


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

#descriptionObject (readonly)

Returns the value of attribute description.



534
535
536
# File 'lib/tesco.rb', line 534

def description
  @description
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



534
535
536
# File 'lib/tesco.rb', line 534

def image_url
  @image_url
end

#valid_fromObject (readonly)

Returns the value of attribute valid_from.



535
536
537
# File 'lib/tesco.rb', line 535

def valid_from
  @valid_from
end

#valid_untilObject (readonly)

Returns the value of attribute valid_until.



535
536
537
# File 'lib/tesco.rb', line 535

def valid_until
  @valid_until
end

#validityObject (readonly)

Returns the value of attribute validity.



534
535
536
# File 'lib/tesco.rb', line 534

def validity
  @validity
end