Class: AsciiChem::Model::Spectrum
- Defined in:
- lib/asciichem/model/spectrum.rb
Overview
A spectroscopy result: NMR, IR, MS, UV-Vis peaks.
Syntax:
spectrum[nmr](type=1H,solvent=CDCl3){
1.2: 3H s "CH3"
7.2: 5H m "C6H5"
}
spectrum[ir]{
3300: broad "O-H stretch"
}
spectrum[ms]{
18: 100% "M+"
}
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#peaks ⇒ Object
Returns the value of attribute peaks.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #children ⇒ Object
- #diagnostic_label ⇒ Object
-
#initialize(type: nil, params: {}, peaks: []) ⇒ Spectrum
constructor
A new instance of Spectrum.
- #to_s ⇒ Object
- #value_attributes ⇒ Object
Methods inherited from Node
#==, #accept, #hash, short_name, #to_cml, #to_html, #to_latex, #to_mathml, #to_svg, #to_text
Constructor Details
#initialize(type: nil, params: {}, peaks: []) ⇒ Spectrum
Returns a new instance of Spectrum.
23 24 25 26 27 |
# File 'lib/asciichem/model/spectrum.rb', line 23 def initialize(type: nil, params: {}, peaks: []) @type = type @params = params @peaks = peaks end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
21 22 23 |
# File 'lib/asciichem/model/spectrum.rb', line 21 def params @params end |
#peaks ⇒ Object
Returns the value of attribute peaks.
21 22 23 |
# File 'lib/asciichem/model/spectrum.rb', line 21 def peaks @peaks end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'lib/asciichem/model/spectrum.rb', line 21 def type @type end |
Instance Method Details
#children ⇒ Object
33 34 35 |
# File 'lib/asciichem/model/spectrum.rb', line 33 def children [] end |
#diagnostic_label ⇒ Object
37 38 39 |
# File 'lib/asciichem/model/spectrum.rb', line 37 def diagnostic_label "Spectrum(#{type || 'unknown'})" end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/asciichem/model/spectrum.rb', line 41 def to_s "spectrum[#{type}](#{params.map { |k, v| "#{k}=#{v}" }.join(',')})" end |
#value_attributes ⇒ Object
29 30 31 |
# File 'lib/asciichem/model/spectrum.rb', line 29 def value_attributes { type: type, params: params, peaks: peaks } end |