Class: InciScore::Ingredient

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

Constant Summary collapse

SLASH =
"/"
SLASH_RULE =
/(?<!ate)\//
PARENTHESIS =
%w[( ) [ ]]
DETAILS_RULE =
/(\(.+\)|\[.+\])/

Instance Method Summary collapse

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_sObject



13
14
15
# File 'lib/inci_score/ingredient.rb', line 13

def to_s
  values.join(SLASH)
end

#valuesObject



17
18
19
# File 'lib/inci_score/ingredient.rb', line 17

def values
  @values ||= synonims.unshift(name).compact
end