Module: Parse::Phrase

Defined in:
lib/ascension/parse.rb

Defined Under Namespace

Classes: Base, Basic, For, If, On

Class Method Summary collapse

Class Method Details

.parsed(raw) ⇒ Object



61
62
63
64
# File 'lib/ascension/parse.rb', line 61

def self.parsed(raw)
  cls = phrase_class(raw)
  cls.new(:raw => raw)
end

.phrase_class(raw) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/ascension/parse.rb', line 52

def self.phrase_class(raw)
  a = raw.split(" ")
  h = {"on" => On, "if" => If, "for" => For}
  if a.size == 3
    h[a[1]]
  else
    Basic
  end
end