Class: Denso::Calendar
- Inherits:
-
Object
- Object
- Denso::Calendar
- Defined in:
- lib/denso/calendar.rb,
lib/denso/calendar/cli.rb,
lib/denso/calendar/date.rb,
lib/denso/calendar/version.rb,
lib/denso/calendar/formatter.rb,
lib/denso/calendar/formatter/ical.rb,
lib/denso/calendar/formatter/plain.rb
Defined Under Namespace
Modules: Formatter Classes: Cli, Date
Constant Summary collapse
- URI =
'https://www.denso.com/jp/ja/about-us/calendar/'
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
- #days ⇒ Array[Denso::Calendar::Date] readonly
Class Method Summary collapse
-
.load(type = :production) ⇒ Array[Denso::Calendar]
Loads calendars from DENSO site.
- .uri ⇒ Object
Instance Method Summary collapse
-
#business_days ⇒ Array[Denso::Calendar::Date]
Returns all business days in the Calendar.
-
#holidays ⇒ Array[Denso::Calendar::Date]
Returns all holidays in the Calendar.
-
#initialize(tables_doc) ⇒ Calendar
constructor
A new instance of Calendar.
Constructor Details
#initialize(tables_doc) ⇒ Calendar
Returns a new instance of Calendar.
35 36 37 38 39 |
# File 'lib/denso/calendar.rb', line 35 def initialize(tables_doc) @doc = tables_doc parse end |
Instance Attribute Details
#days ⇒ Array[Denso::Calendar::Date] (readonly)
33 34 35 |
# File 'lib/denso/calendar.rb', line 33 def days @days end |
Class Method Details
.load(type = :production) ⇒ Array[Denso::Calendar]
Loads calendars from DENSO site
20 21 22 23 24 25 26 |
# File 'lib/denso/calendar.rb', line 20 def self.load(type = :production) content = Net::HTTP.get(uri) doc = Nokogiri::HTML(content) tables = doc.xpath("//h2/a[@id='#{type}']/../../following-sibling::div[contains(@class, 'denso-calendar')][1]") Calendar.new(tables) end |
.uri ⇒ Object
28 29 30 |
# File 'lib/denso/calendar.rb', line 28 def self.uri @uri ||= ::URI.parse(URI) end |
Instance Method Details
#business_days ⇒ Array[Denso::Calendar::Date]
Returns all business days in the Calendar
45 46 47 |
# File 'lib/denso/calendar.rb', line 45 def business_days @business_days ||= days.select(&:business_day?) end |
#holidays ⇒ Array[Denso::Calendar::Date]
Returns all holidays in the Calendar
53 54 55 |
# File 'lib/denso/calendar.rb', line 53 def holidays @holidays ||= days.select(&:holiday?) end |