Class: NexusParser::NexusParser::Note

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Note



90
91
92
# File 'lib/nexus_parser.rb', line 90

def initialize(options = {})
  @vars = options
end

Instance Attribute Details

#varsObject

Returns the value of attribute vars.



89
90
91
# File 'lib/nexus_parser.rb', line 89

def vars
  @vars
end

Instance Method Details

#noteObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/nexus_parser.rb', line 94

def note
  n = ''
  if @vars[:tf]
    n = @vars[:tf]
  elsif @vars[:text]
    n = @vars[:text]
  else
    n = 'No text recovered, possible parsing error.'
  end

  # THIS IS A HACK for handling the TF = (CM <note>) format, I assume there will be other params in the future beyond CM, at that point move processing to the parser
  if n[0..2] =~ /\A\s*\(\s*CM\s*/i
    n.strip!
    n = n[1..-2] if n[0..0] == "(" # get rid of quotation marks
    n.strip!
    n = n[2..-1] if n[0..1].downcase == "cm" # strip CM
    n.strip!
    n = n[1..-2] if n[0..0] == "'" # get rid of quote marks
    n = n[1..-2] if n[0..0] == '"'
  end
  n.strip
end