Class: Chemicalml::Model::Formula

Inherits:
Node
  • Object
show all
Defined in:
lib/chemicalml/model/formula.rb

Overview

Canonical formula. Three complementary forms: a structured atom_array, a concise string (e.g. "C 1 H 4 O 1"), or an inline representation (e.g. LaTeX "H_3C-OH").

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #children, #hash, short_name

Constructor Details

#initialize(id: nil, concise: nil, inline: nil, formal_charge: nil, count: nil, title: nil, convention: nil, dict_ref: nil) ⇒ Formula

Returns a new instance of Formula.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/chemicalml/model/formula.rb', line 12

def initialize(id: nil, concise: nil, inline: nil,
               formal_charge: nil, count: nil, title: nil,
               convention: nil, dict_ref: nil)
  @id = id
  @concise = concise
  @inline = inline
  @formal_charge = formal_charge
  @count = count
  @title = title
  @convention = convention
  @dict_ref = dict_ref
end

Instance Attribute Details

#conciseObject

Returns the value of attribute concise.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def concise
  @concise
end

#conventionObject

Returns the value of attribute convention.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def convention
  @convention
end

#countObject

Returns the value of attribute count.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def count
  @count
end

#dict_refObject

Returns the value of attribute dict_ref.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def dict_ref
  @dict_ref
end

#formal_chargeObject

Returns the value of attribute formal_charge.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def formal_charge
  @formal_charge
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def id
  @id
end

#inlineObject

Returns the value of attribute inline.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def inline
  @inline
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/chemicalml/model/formula.rb', line 9

def title
  @title
end

Instance Method Details

#value_attributesObject



25
26
27
28
29
30
31
# File 'lib/chemicalml/model/formula.rb', line 25

def value_attributes
  {
    id: id, concise: concise, inline: inline,
    formal_charge: formal_charge, count: count, title: title,
    convention: convention, dict_ref: dict_ref
  }
end