Class: SparkApi::Models::RentalCalendar

Inherits:
Base
  • Object
show all
Extended by:
Subresource
Defined in:
lib/spark_api/models/rental_calendar.rb

Constant Summary

Constants included from Paginate

Paginate::DEFAULT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Base

#attributes, #errors, #parent

Instance Method Summary collapse

Methods included from Subresource

build_subclass, find_by_id, find_by_listing_key, parse_date_start_and_end_times

Methods inherited from Base

#connection, connection, count, element_name, element_name=, first, get, #id, #load, #method_missing, #parse_id, path, #path, #persisted?, prefix, prefix=, #resource_pluralized, #resource_uri, #respond_to?, #to_param, #to_partial_path

Methods included from Paginate

#collect, #paginate, #per_page

Methods included from Dirty

#changed, #changed?, #changed_attributes, #changes, #dirty_attributes, #previous_changes

Constructor Details

#initialize(attributes = {}) ⇒ RentalCalendar

Returns a new instance of RentalCalendar.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/spark_api/models/rental_calendar.rb', line 7

def initialize(attributes={})
  # Transform the date strings
  unless attributes['StartDate'].nil?
    date = Date.parse(attributes['StartDate'])
    attributes['StartDate'] = date
  end
  unless attributes['EndDate'].nil?
    date = Date.parse(attributes['EndDate'])
    attributes['EndDate'] = date
  end        
  super(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SparkApi::Models::Base

Instance Method Details

#include_date?(day) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/spark_api/models/rental_calendar.rb', line 20

def include_date? (day)
  day >= self.StartDate && day <= self.EndDate
end