Class: Scopus::XMLResponse::Abstractcitationsresponse
- Inherits:
-
XMLResponseGeneric
- Object
- XMLResponseGeneric
- Scopus::XMLResponse::Abstractcitationsresponse
- Defined in:
- lib/scopus/xml_response/abstract_citation_response.rb
Instance Attribute Summary collapse
-
#column_total ⇒ Object
readonly
Returns the value of attribute column_total.
-
#grand_total ⇒ Object
readonly
Returns the value of attribute grand_total.
-
#h_index ⇒ Object
readonly
How many records are in the xml.
-
#later_total ⇒ Object
readonly
Returns the value of attribute later_total.
-
#n_records ⇒ Object
readonly
p @records.
-
#prev_total ⇒ Object
readonly
Returns the value of attribute prev_total.
-
#range_total ⇒ Object
readonly
Returns the value of attribute range_total.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
-
#year_range ⇒ Object
readonly
Returns the value of attribute year_range.
Instance Method Summary collapse
- #citations_by_year(scopus_id) ⇒ Object
- #citations_outside_range?(scopus_id) ⇒ Boolean
- #empty_record?(scopus_id) ⇒ Boolean
- #get_record(scopus_id) ⇒ Object
- #process ⇒ Object
- #scopus_id_a ⇒ Object
Constructor Details
This class inherits a constructor from Scopus::XMLResponse::XMLResponseGeneric
Instance Attribute Details
#column_total ⇒ Object (readonly)
Returns the value of attribute column_total.
36 37 38 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 36 def column_total @column_total end |
#grand_total ⇒ Object (readonly)
Returns the value of attribute grand_total.
38 39 40 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 38 def grand_total @grand_total end |
#h_index ⇒ Object (readonly)
How many records are in the xml
32 33 34 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 32 def h_index @h_index end |
#later_total ⇒ Object (readonly)
Returns the value of attribute later_total.
35 36 37 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 35 def later_total @later_total end |
#n_records ⇒ Object (readonly)
p @records
67 68 69 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 67 def n_records @n_records end |
#prev_total ⇒ Object (readonly)
Returns the value of attribute prev_total.
34 35 36 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 34 def prev_total @prev_total end |
#range_total ⇒ Object (readonly)
Returns the value of attribute range_total.
37 38 39 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 37 def range_total @range_total end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
39 40 41 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 39 def records @records end |
#year_range ⇒ Object (readonly)
Returns the value of attribute year_range.
33 34 35 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 33 def year_range @year_range end |
Instance Method Details
#citations_by_year(scopus_id) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 83 def citations_by_year(scopus_id) record=get_record(scopus_id) return nil if record[:cc].length==0 year_range.each_index.inject({}) {|ac,i| ac[@year_range[i]]=record[:cc][i] ac } end |
#citations_outside_range?(scopus_id) ⇒ Boolean
91 92 93 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 91 def citations_outside_range?(scopus_id) @grand_total!=@range_total end |
#empty_record?(scopus_id) ⇒ Boolean
79 80 81 82 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 79 def empty_record?(scopus_id) record=get_record(scopus_id) record[:cc]==[] end |
#get_record(scopus_id) ⇒ Object
74 75 76 77 78 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 74 def get_record(scopus_id) record=@records.find {|r| r[:scopus_id]==scopus_id} raise("Record doesn't exists") unless record record end |
#process ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 41 def process #p @xml @h_index=process_path(@xml,"//h-index").to_i @year_range=@xml.xpath("//columnHeading").map {|xx| xx.text.to_i} @prev_total=process_path(@xml,"//prevColumnTotal").to_i @later_total=process_path(@xml,"//laterColumnTotal").to_i @column_total=@xml.xpath("//columnTotal").map {|xx| xx.text.to_i} @range_total=process_path(@xml,"//rangeColumnTotal").to_i @grand_total=process_path(@xml,"//grandTotal").to_i @records=xml.xpath("//citeInfo").map do |x| scopus_id=process_path(x,".//dc:identifier") pcc=process_path(x,".//pcc").to_i cc=x.xpath(".//cc").map {|xx| xx.text.to_i} lcc=process_path(x,".//lcc").to_i #if scopus_id=="SCOPUS_ID:84866769122" # p x # p({:scopus_id=>scopus_id,:pcc=>pcc,:lcc=>lcc,:cc=>cc}) #end {:scopus_id=>scopus_id,:pcc=>pcc,:lcc=>lcc,:cc=>cc} end #p @records end |
#scopus_id_a ⇒ Object
71 72 73 |
# File 'lib/scopus/xml_response/abstract_citation_response.rb', line 71 def scopus_id_a @records.map {|r| r[:scopus_id]} end |