Sha256: fd5b08333b5c3eb3738560259c41181edbe614c1d823b4133d3758ca2d6b0685
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
require 'open-uri' require 'json' require 'date' module Sist02 module CiNii module_function def article_ref(naid) begin html = open("http://ci.nii.ac.jp/naid/#{naid}.json").read json = JSON.parser.new(html) hash = json.parse["@graph"][0] title = hash["dc:title"][0]["@value"] creator = hash["dc:creator"][0][0]["@value"] publication_name = hash["prism:publicationName"][0]["@value"] year = hash["dc:date"].match(/\d{4}/) volume = hash["prism:volume"] number = hash["prism:number"] start_p = hash["prism:startingPage"] end_p = hash["prism:endingPage"] result = "#{creator}. #{title}. #{publication_name}. #{year}, #{volume}(#{number}), p. #{start_p}-#{end_p}." rescue => e result = e end return result end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sist02-0.1.3 | lib/sist02/cinii.rb |