Class: ICat4JSON::ICat4JSON

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeICat4JSON

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

#icatObject

Returns the value of attribute icat


8
9
10
# File 'lib/icat4json.rb', line 8

def icat
  @icat
end

#jsonObject

Returns the value of attribute json


8
9
10
# File 'lib/icat4json.rb', line 8

def json
  @json
end