Class: DwcAgent::Parser
- Inherits:
-
Object
- Object
- DwcAgent::Parser
- Defined in:
- lib/dwc_agent/parser.rb
Class Attribute Summary collapse
-
.defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Instance Attribute Summary collapse
-
#namae ⇒ Object
readonly
Returns the value of attribute namae.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(name) ⇒ Array
Parses the passed-in string and returns a list of names.
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
28 29 30 31 |
# File 'lib/dwc_agent/parser.rb', line 28 def initialize( = {}) @options = self.class.defaults.merge() @namae = Namae::Parser.new(@options) end |
Class Attribute Details
.defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
19 20 21 |
# File 'lib/dwc_agent/parser.rb', line 19 def defaults @defaults end |
Instance Attribute Details
#namae ⇒ Object (readonly)
Returns the value of attribute namae.
26 27 28 |
# File 'lib/dwc_agent/parser.rb', line 26 def namae @namae end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/dwc_agent/parser.rb', line 26 def @options end |
Class Method Details
.instance ⇒ Object
21 22 23 |
# File 'lib/dwc_agent/parser.rb', line 21 def instance Thread.current[:dwc_agent_parser] ||= new end |
Instance Method Details
#parse(name) ⇒ Array
Parses the passed-in string and returns a list of names.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dwc_agent/parser.rb', line 37 def parse(name) return [] if name.nil? || name == "" name.gsub!([:strip_out_regex], ' ') name.gsub!([:tidy_remains_regex], '') name.gsub!([:subs_regex], CHAR_SUBS) [:complex_separators_regex].each{|k| name.gsub!(k[0], k[1])} name.gsub!([:residual_terminators_regex], '') name.squeeze!(' ') name.strip! namae.parse(name) end |