class Get::Parser

Constants

ALL_CLASS_REGEX
CLASS_NAME_BY_ERROR
CLASS_REGEX

Attributes

class_name[RW]
method[RW]
result_entity[RW]

Public Class Methods

new(class_name) click to toggle source
# File lib/get/parser.rb, line 8
def initialize(class_name)
  raise Get::Errors::InvalidClassName.new(CLASS_NAME_BY_ERROR) if class_name.to_s.split('By').length > 2

  @class_name = class_name
  @match = match_result
end

Public Instance Methods

key() click to toggle source
# File lib/get/parser.rb, line 19
def key
  @key_string.present? ? @key_string.symbolize : nil
end
match?() click to toggle source
# File lib/get/parser.rb, line 15
def match?
  !!@match
end
match_result() click to toggle source
# File lib/get/parser.rb, line 23
def match_result
  @match = class_name.to_s.match(ALL_CLASS_REGEX)
  if @match
    @method, @result_entity = @match.values_at(1, 2)
  else
    @match = class_name.to_s.match(CLASS_REGEX)
    @result_entity, @method, @key_string = @match.values_at(1, 2, 3) if @match
  end
  @match
end