Class: Kaede::SyoboiCalendar
- Inherits:
-
Object
- Object
- Kaede::SyoboiCalendar
- Defined in:
- lib/kaede/syoboi_calendar.rb
Defined Under Namespace
Classes: HttpError
Constant Summary collapse
- HOST =
'cal.syoboi.jp'
- PORT =
80
Instance Method Summary collapse
- #cal_chk(params = {}) ⇒ Object
-
#initialize ⇒ SyoboiCalendar
constructor
A new instance of SyoboiCalendar.
Constructor Details
#initialize ⇒ SyoboiCalendar
Returns a new instance of SyoboiCalendar.
20 21 22 |
# File 'lib/kaede/syoboi_calendar.rb', line 20 def initialize @http = Net::HTTP.new(HOST, PORT) end |
Instance Method Details
#cal_chk(params = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kaede/syoboi_calendar.rb', line 24 def cal_chk(params = {}) path = '/cal_chk.php' q = params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('=') if !q.empty? path += '?' + q end res = @http.get(path) case res when Net::HTTPOK Program.from_xml(Nokogiri::HTML.parse(res.body)) else raise HttpError.new(res) end end |