Sha256: eb76c02b949b6eb3ebccb2d0334c129cd0c0e2a7405a77985940b260cf65af05

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

class String
  def adjective?
    'old' == self
  end
  
  def determiner?
    'the' == self
  end
  
  def noun?
    case self
    when 'man', 'avocados', 'cookie', 'monster', 'street'
      true
    else
      false
    end
  end
  
  def present_participle?
    'smiling' == self
  end
  
  def past_participle?
    'eaten' == self
  end
  
  def preposition?
    'in' == self
  end
  
  def preterite
    if 'eaten' == self
      return 'ate'
    else
      return self
    end
  end
  
  def pronoun?
    'you' == self
  end
  
  def verb?
    case self
    when 'grows', 'eat', 'ate', 'was'
      true
    else
      false
    end
  end
  
  def matches_for(pattern)
    matches = []
    self.gsub(pattern) do |match|
      matches << match
    end
    return matches
  end
  
  def number_in_quotes
    matches_for(/".*?"/).length
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
odin-0.0.4 simple_atn/string.rb
odin-0.1.0.alpha.1 simple_atn/string.rb