module Tsukuba::GC
Constants
- VERSION
Public Instance Methods
dump_json(schedules, io = nil)
click to toggle source
# File lib/tsukuba/gc.rb, line 30 def dump_json(schedules, io = nil) obj = generate_json_object(schedules) json_str = JSON.pretty_generate(obj) + "\n" if io.nil? json_str else io.write(json_str) end end
generate_json_object(schedules)
click to toggle source
# File lib/tsukuba/gc.rb, line 26 def generate_json_object(schedules) schedules.map { |schedule| {date: schedule.time.to_s, type: schedule.type_ja} } end
parse(year, file_path)
click to toggle source
# File lib/tsukuba/gc.rb, line 12 def parse(year, file_path) pages = Magick::Image.read(file_path) time = Time.new(year, 4) schedules = [] 12.times do |i| calendar = Calendar.new(time.year, time.month, pages[(i/4) + 1]) schedules.concat(calendar.schedules) time = time.next_month end return schedules end