Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/orchid/compiler.rb

Instance Method Summary collapse

Instance Method Details

#as_argObject



63
64
65
# File 'lib/orchid/compiler.rb', line 63

def as_arg
  return "'#{self.strip}'"
end

#as_ivObject



55
56
57
# File 'lib/orchid/compiler.rb', line 55

def as_iv
  return "@#{self.strip.underscoreize}"
end

#as_optObject



67
68
69
# File 'lib/orchid/compiler.rb', line 67

def as_opt
  return self.deunderscoreize.singularize.deivize
end

#as_paramObject



59
60
61
# File 'lib/orchid/compiler.rb', line 59

def as_param
  return (self.length > 1 ? "--" : "-") + self.deunderscoreize.deivize.singularize
end

#deivizeObject



51
52
53
# File 'lib/orchid/compiler.rb', line 51

def deivize
  return self.gsub(/\@/, '')
end

#deunderscoreizeObject



47
48
49
# File 'lib/orchid/compiler.rb', line 47

def deunderscoreize
  return self.gsub(/\_/, '-')
end

#plural?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/orchid/compiler.rb', line 31

def plural?
  return self.match(/s$/i) ? true : false
end

#pluralizeObject



35
36
37
# File 'lib/orchid/compiler.rb', line 35

def pluralize
  return self.plural? ? self : "#{self}s"
end

#singularizeObject



39
40
41
# File 'lib/orchid/compiler.rb', line 39

def singularize
  return self.plural? ? self.gsub(/s$/i, '') : self
end

#underscoreizeObject



43
44
45
# File 'lib/orchid/compiler.rb', line 43

def underscoreize
  return self.gsub(/\-/, '_')
end