noted / scholar

Search for and cite MLA sources.
MIT License
6 stars 4 forks source link

Citation modifies source hash #4

Closed ethnt closed 11 years ago

ethnt commented 11 years ago
[1] pry(main)> hash = {
[1] pry(main)*   :type => :book,
[1] pry(main)*   :title => "The Fault in Our Stars",
[1] pry(main)*   :contributors => [
[1] pry(main)*     {
[1] pry(main)*       :role => :author,
[1] pry(main)*       :first => "John",
[1] pry(main)*       :last => "Green"
[1] pry(main)*     }  
[1] pry(main)*   ],  
[1] pry(main)*   :publisher => "Dutton Books",
[1] pry(main)*   :city => "New York",
[1] pry(main)*   :year => "2012"
[1] pry(main)* }  
=> {:type=>:book,
 :title=>"The Fault in Our Stars",
 :contributors=>[{:role=>:author, :first=>"John", :last=>"Green"}],
 :publisher=>"Dutton Books",
 :city=>"New York",
 :year=>"2012"}
[2] pry(main)> s = Scholar::Citation.new(hash)
=> #<Scholar::Citation:0xa44f8a4
 @data=
  {:authors=>"Green, John.",
   :title=>"<em>The Fault in Our Stars</em>.",
   :city=>"New York:",
   :publisher=>"Dutton Books,",
   :year=>"2012."},
 @html=
  "Green, John. <em>The Fault in Our Stars</em>. New York: Dutton Books, 2012.">
[3] pry(main)> hash
=> {:title=>"The Fault in Our Stars",
 :publisher=>"Dutton Books",
 :city=>"New York",
 :year=>"2012"}

It should not modify a local variable or hash.

ethnt commented 11 years ago

Clarification: it only orders attribute hash, and does not format.