Class: EveApp::ItemParser::Line

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

Constant Summary collapse

REGEX =
/(?<=\s|\t|^)(x?\s?[0-9]+\s?x?)(?=\s|\t|$)/i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Line

Returns a new instance of Line.



71
72
73
74
75
76
77
# File 'lib/eve_app/item_parser.rb', line 71

def initialize(text)
  @text = text
  @parts = text.split(/\t/)
  @quantity_words = find_quantity_words
  @type = EveApp::Type.where(name: search_strings).first
  @quantity = find_quantity if type
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



69
70
71
# File 'lib/eve_app/item_parser.rb', line 69

def parts
  @parts
end

#quantityObject (readonly)

Returns the value of attribute quantity.



69
70
71
# File 'lib/eve_app/item_parser.rb', line 69

def quantity
  @quantity
end

#quantity_wordsObject (readonly)

Returns the value of attribute quantity_words.



69
70
71
# File 'lib/eve_app/item_parser.rb', line 69

def quantity_words
  @quantity_words
end

#textObject (readonly)

Returns the value of attribute text.



69
70
71
# File 'lib/eve_app/item_parser.rb', line 69

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



69
70
71
# File 'lib/eve_app/item_parser.rb', line 69

def type
  @type
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/eve_app/item_parser.rb', line 79

def valid?
  !!type
end