Class: InciScore::Ingredient
- Inherits:
-
Object
- Object
- InciScore::Ingredient
- Defined in:
- lib/inci_score/ingredient.rb
Constant Summary collapse
- SLASH =
"/"- SLASH_RULE =
/(?<!ate)\//- PARENTHESIS =
%w[( ) [ ]]
- DETAILS_RULE =
/(\(.+\)|\[.+\])/
Instance Method Summary collapse
-
#initialize(raw) ⇒ Ingredient
constructor
A new instance of Ingredient.
- #to_s ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(raw) ⇒ Ingredient
Returns a new instance of Ingredient.
8 9 10 11 |
# File 'lib/inci_score/ingredient.rb', line 8 def initialize(raw) @raw = raw.to_s @tokens = @raw.split(SLASH_RULE).map(&:strip) end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/inci_score/ingredient.rb', line 13 def to_s values.join(SLASH) end |
#values ⇒ Object
17 18 19 |
# File 'lib/inci_score/ingredient.rb', line 17 def values @values ||= synonims.unshift(name).compact end |