Class: CommonChemistry::DetailResult

Inherits:
Object
  • Object
show all
Defined in:
lib/commonchemistry.rb

Overview

Represents detailed information about a substance

Instance Attribute Summary collapse

Instance Method Summary collapse

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_smileObject (readonly)

Returns the value of attribute canonical_smile.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def canonical_smile
  @canonical_smile
end

#experimental_propertiesObject (readonly)

Returns the value of attribute experimental_properties.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def experimental_properties
  @experimental_properties
end

#imageObject (readonly)

Returns the value of attribute image.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def image
  @image
end

#inchiObject (readonly)

Returns the value of attribute inchi.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def inchi
  @inchi
end

#inchi_keyObject (readonly)

Returns the value of attribute inchi_key.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def inchi_key
  @inchi_key
end

#molecular_formulaObject (readonly)

Returns the value of attribute molecular_formula.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def molecular_formula
  @molecular_formula
end

#molecular_massObject (readonly)

Returns the value of attribute molecular_mass.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def molecular_mass
  @molecular_mass
end

#nameObject (readonly)

Returns the value of attribute name.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def name
  @name
end

#property_citationsObject (readonly)

Returns the value of attribute property_citations.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def property_citations
  @property_citations
end

#replaced_rnsObject (readonly)

Returns the value of attribute replaced_rns.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def replaced_rns
  @replaced_rns
end

#rnObject (readonly)

Returns the value of attribute rn.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def rn
  @rn
end

#smileObject (readonly)

Returns the value of attribute smile.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def smile
  @smile
end

#synonymsObject (readonly)

Returns the value of attribute synonyms.



127
128
129
# File 'lib/commonchemistry.rb', line 127

def synonyms
  @synonyms
end

#uriObject (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

Parameters:

  • filename (String)

    The filename to save the image as



152
153
154
# File 'lib/commonchemistry.rb', line 152

def save_image(filename)
  File.open(filename, 'w') { |file| file.write(@image) }
end