Class: CommonChemistry::DetailResult
- Inherits:
-
Object
- Object
- CommonChemistry::DetailResult
- Defined in:
- lib/commonchemistry.rb
Overview
Represents detailed information about a substance
Instance Attribute Summary collapse
-
#canonical_smile ⇒ Object
readonly
Returns the value of attribute canonical_smile.
-
#experimental_properties ⇒ Object
readonly
Returns the value of attribute experimental_properties.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#inchi ⇒ Object
readonly
Returns the value of attribute inchi.
-
#inchi_key ⇒ Object
readonly
Returns the value of attribute inchi_key.
-
#molecular_formula ⇒ Object
readonly
Returns the value of attribute molecular_formula.
-
#molecular_mass ⇒ Object
readonly
Returns the value of attribute molecular_mass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#property_citations ⇒ Object
readonly
Returns the value of attribute property_citations.
-
#replaced_rns ⇒ Object
readonly
Returns the value of attribute replaced_rns.
-
#rn ⇒ Object
readonly
Returns the value of attribute rn.
-
#smile ⇒ Object
readonly
Returns the value of attribute smile.
-
#synonyms ⇒ Object
readonly
Returns the value of attribute synonyms.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(data) ⇒ DetailResult
constructor
A new instance of DetailResult.
-
#save_image(filename) ⇒ Object
Saves the SVG image to a file.
Constructor Details
#initialize(data) ⇒ DetailResult
Returns a new instance of DetailResult.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/commonchemistry.rb', line 132 def initialize(data) @uri = data['uri'] @rn = data['rn'] @name = data['name'] @image = data['image'] @inchi = data['inchi'] @inchi_key = data['inchiKey'] @smile = data['smile'] @canonical_smile = data['canonicalSmile'] @molecular_formula = data['molecularFormula'] @molecular_mass = data['molecularMass'] @experimental_properties = (data['experimentalProperties'] || []).map { |prop| ExperimentalProperty.new(prop) } @property_citations = (data['propertyCitations'] || []).map { |citation| PropertyCitation.new(citation) } @synonyms = data['synonyms'] || [] @replaced_rns = data['replacedRns'] || [] end |
Instance Attribute Details
#canonical_smile ⇒ Object (readonly)
Returns the value of attribute canonical_smile.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def canonical_smile @canonical_smile end |
#experimental_properties ⇒ Object (readonly)
Returns the value of attribute experimental_properties.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def experimental_properties @experimental_properties end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def image @image end |
#inchi ⇒ Object (readonly)
Returns the value of attribute inchi.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def inchi @inchi end |
#inchi_key ⇒ Object (readonly)
Returns the value of attribute inchi_key.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def inchi_key @inchi_key end |
#molecular_formula ⇒ Object (readonly)
Returns the value of attribute molecular_formula.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def molecular_formula @molecular_formula end |
#molecular_mass ⇒ Object (readonly)
Returns the value of attribute molecular_mass.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def molecular_mass @molecular_mass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def name @name end |
#property_citations ⇒ Object (readonly)
Returns the value of attribute property_citations.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def property_citations @property_citations end |
#replaced_rns ⇒ Object (readonly)
Returns the value of attribute replaced_rns.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def replaced_rns @replaced_rns end |
#rn ⇒ Object (readonly)
Returns the value of attribute rn.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def rn @rn end |
#smile ⇒ Object (readonly)
Returns the value of attribute smile.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def smile @smile end |
#synonyms ⇒ Object (readonly)
Returns the value of attribute synonyms.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def synonyms @synonyms end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
127 128 129 |
# File 'lib/commonchemistry.rb', line 127 def uri @uri end |
Instance Method Details
#save_image(filename) ⇒ Object
Saves the SVG image to a file
152 153 154 |
# File 'lib/commonchemistry.rb', line 152 def save_image(filename) File.open(filename, 'w') { |file| file.write(@image) } end |