Class: CommonChemistry::SearchResult
- Inherits:
-
Object
- Object
- CommonChemistry::SearchResult
- Defined in:
- lib/commonchemistry.rb
Overview
Represents an individual search result
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rn ⇒ Object
readonly
Returns the value of attribute rn.
Instance Method Summary collapse
-
#initialize(data) ⇒ SearchResult
constructor
A new instance of SearchResult.
-
#save_image(filename) ⇒ Object
Saves the SVG image to a file.
Constructor Details
#initialize(data) ⇒ SearchResult
Returns a new instance of SearchResult.
111 112 113 114 115 |
# File 'lib/commonchemistry.rb', line 111 def initialize(data) @rn = data['rn'] @name = data['name'] @image = data['image'] end |
Instance Attribute Details
#image ⇒ Object (readonly)
Returns the value of attribute image.
109 110 111 |
# File 'lib/commonchemistry.rb', line 109 def image @image end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
109 110 111 |
# File 'lib/commonchemistry.rb', line 109 def name @name end |
#rn ⇒ Object (readonly)
Returns the value of attribute rn.
109 110 111 |
# File 'lib/commonchemistry.rb', line 109 def rn @rn end |
Instance Method Details
#save_image(filename) ⇒ Object
Saves the SVG image to a file
120 121 122 |
# File 'lib/commonchemistry.rb', line 120 def save_image(filename) File.open(filename, 'w') { |file| file.write(@image) } end |