class Parsable::Parser

Constants

REGEX

Attributes

original_string[RW]
strings[RW]

Public Class Methods

new(args={}) click to toggle source
# File lib/parsable/parser.rb, line 8
def initialize args={}
  @original_string = args.fetch(:string).to_s
end

Public Instance Methods

parse() click to toggle source
# File lib/parsable/parser.rb, line 12
def parse
  strings.map do |string|
    object, attribute = capture(string)

    Parsable::ParsedItem.new(\
      :original  => string,
      :object    => object,
      :attribute => attribute
    )
  end
end

Private Instance Methods

capture(string) click to toggle source
# File lib/parsable/parser.rb, line 26
def capture string
  [capture_object(string), capture_attribute(string)]
end
capture_attribute(string) click to toggle source
# File lib/parsable/parser.rb, line 38
def capture_attribute string
  string[/\w*\.?(\S*)/, 1]
end
capture_object(string) click to toggle source
# File lib/parsable/parser.rb, line 34
def capture_object string
  string[/(\w*)\.?\S*/, 1]
end