Class: ICat4JSON::ICat4JSON
- Inherits:
-
Object
- Object
- ICat4JSON::ICat4JSON
- Defined in:
- lib/icat4json.rb
Constant Summary collapse
- ICAT4JSON_URL =
"http://isec-myjvn-feed1.ipa.go.jp/IPARssReader.php?1456207434&tool=icatw"
Instance Attribute Summary collapse
-
#icat ⇒ Object
Returns the value of attribute icat.
-
#json ⇒ Object
Returns the value of attribute json.
Instance Method Summary collapse
-
#initialize ⇒ ICat4JSON
constructor
A new instance of ICat4JSON.
Constructor Details
#initialize ⇒ ICat4JSON
Returns a new instance of ICat4JSON.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/icat4json.rb', line 11 def initialize uri = URI.parse(ICAT4JSON_URL) http = Net::HTTP.get(uri) @json = JSON.parse(http) struct_icat = Struct.new(:itemdata, :docTitle, :docTitleFix, :docLink, :docDate) struct_item = Struct.new(:item_title, :item_link, :item_date, :item_identifier) @icat = struct_icat.new @json.each {|k, v| icat[k] = v unless k == "itemdata" } @icat[:itemdata] = [] @json["itemdata"].each do |itemdata| item = struct_item.new itemdata.each do |k,v| item[k] = v end @icat[:itemdata].push item end true end |
Instance Attribute Details
#icat ⇒ Object
Returns the value of attribute icat
8 9 10 |
# File 'lib/icat4json.rb', line 8 def icat @icat end |
#json ⇒ Object
Returns the value of attribute json
8 9 10 |
# File 'lib/icat4json.rb', line 8 def json @json end |