Class: Fab::Library
Constant Summary collapse
- NONE_APIKEY_TEMPLATE =
<<-EOS not set apikey fab registration -apikey,-a [APIKEY] EOS
Constants inherited from Book
Constants inherited from Output
Output::LINE_BREAK_TEMPLATE, Output::LINE_TEMPLATE
Instance Method Summary collapse
-
#initialize ⇒ Library
constructor
A new instance of Library.
- #library_get_params ⇒ Object
- #library_set_param(pref, city) ⇒ Object
Methods inherited from Book
#book_get_params, #book_set_param
Methods inherited from Output
Constructor Details
#initialize ⇒ Library
Returns a new instance of Library.
96 97 98 |
# File 'lib/fab.rb', line 96 def initialize() @library_send_param = "http://api.calil.jp/library?" end |
Instance Method Details
#library_get_params ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/fab.rb', line 115 def library_get_params() encode_uri = URI.encode(@library_send_param) get_xml = open(encode_uri).read convert_json = Hash.from_xml(get_xml).to_json result = JSON.load(convert_json) @libraries = Hash.new { | h , k | h[k] = {} } count_id(result) for i in 0..@id_count @libraries[i]["systemid"] = result["Libraries"]["Library"][i]["systemid"] @libraries[i]["formal"] = result["Libraries"]["Library"][i]["formal"] end end |
#library_set_param(pref, city) ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fab.rb', line 104 def library_set_param(pref,city) begin @library_send_param << "appkey=#{Fab::Apikey::APIKEY}" rescue puts NONE_APIKEY_TEMPLATE exit end @library_send_param << "&pref=#{pref}" @library_send_param << "&city=#{city}" end |