Class: PubChemAPI::CompoundRecord
- Inherits:
-
APIResponse
- Object
- APIResponse
- PubChemAPI::CompoundRecord
- Defined in:
- lib/pubchem_api.rb
Instance Attribute Summary collapse
-
#canonical_smiles ⇒ Object
readonly
Returns the value of attribute canonical_smiles.
-
#cid ⇒ Object
readonly
Returns the value of attribute cid.
-
#inchi_key ⇒ Object
readonly
Returns the value of attribute inchi_key.
-
#molecular_formula ⇒ Object
readonly
Returns the value of attribute molecular_formula.
-
#molecular_weight ⇒ Object
readonly
Returns the value of attribute molecular_weight.
Instance Method Summary collapse
-
#initialize(data) ⇒ CompoundRecord
constructor
A new instance of CompoundRecord.
Constructor Details
#initialize(data) ⇒ CompoundRecord
Returns a new instance of CompoundRecord.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pubchem_api.rb', line 25 def initialize(data) super(data) compound = data['PC_Compounds'].first @cid = compound['id']['id']['cid'] # Extract properties from the 'props' array props = compound['props'] @molecular_formula = extract_prop(props, 'Molecular Formula') @molecular_weight = extract_prop(props, 'Molecular Weight').to_f @canonical_smiles = extract_prop(props, 'SMILES', 'Canonical') @inchi_key = extract_prop(props, 'InChIKey', 'Standard') end |
Instance Attribute Details
#canonical_smiles ⇒ Object (readonly)
Returns the value of attribute canonical_smiles.
23 24 25 |
# File 'lib/pubchem_api.rb', line 23 def canonical_smiles @canonical_smiles end |
#cid ⇒ Object (readonly)
Returns the value of attribute cid.
23 24 25 |
# File 'lib/pubchem_api.rb', line 23 def cid @cid end |
#inchi_key ⇒ Object (readonly)
Returns the value of attribute inchi_key.
23 24 25 |
# File 'lib/pubchem_api.rb', line 23 def inchi_key @inchi_key end |
#molecular_formula ⇒ Object (readonly)
Returns the value of attribute molecular_formula.
23 24 25 |
# File 'lib/pubchem_api.rb', line 23 def molecular_formula @molecular_formula end |
#molecular_weight ⇒ Object (readonly)
Returns the value of attribute molecular_weight.
23 24 25 |
# File 'lib/pubchem_api.rb', line 23 def molecular_weight @molecular_weight end |