Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/orchid/compiler.rb
Instance Method Summary collapse
- #as_arg ⇒ Object
- #as_iv ⇒ Object
- #as_opt ⇒ Object
- #as_param ⇒ Object
- #deivize ⇒ Object
- #deunderscoreize ⇒ Object
- #plural? ⇒ Boolean
- #pluralize ⇒ Object
- #singularize ⇒ Object
- #underscoreize ⇒ Object
Instance Method Details
#as_arg ⇒ Object
63 64 65 |
# File 'lib/orchid/compiler.rb', line 63 def as_arg return "'#{self.strip}'" end |
#as_iv ⇒ Object
55 56 57 |
# File 'lib/orchid/compiler.rb', line 55 def as_iv return "@#{self.strip.underscoreize}" end |
#as_opt ⇒ Object
67 68 69 |
# File 'lib/orchid/compiler.rb', line 67 def as_opt return self.deunderscoreize.singularize.deivize end |
#as_param ⇒ Object
59 60 61 |
# File 'lib/orchid/compiler.rb', line 59 def as_param return (self.length > 1 ? "--" : "-") + self.deunderscoreize.deivize.singularize end |
#deivize ⇒ Object
51 52 53 |
# File 'lib/orchid/compiler.rb', line 51 def deivize return self.gsub(/\@/, '') end |
#deunderscoreize ⇒ Object
47 48 49 |
# File 'lib/orchid/compiler.rb', line 47 def deunderscoreize return self.gsub(/\_/, '-') end |
#plural? ⇒ Boolean
31 32 33 |
# File 'lib/orchid/compiler.rb', line 31 def plural? return self.match(/s$/i) ? true : false end |
#pluralize ⇒ Object
35 36 37 |
# File 'lib/orchid/compiler.rb', line 35 def pluralize return self.plural? ? self : "#{self}s" end |
#singularize ⇒ Object
39 40 41 |
# File 'lib/orchid/compiler.rb', line 39 def singularize return self.plural? ? self.gsub(/s$/i, '') : self end |
#underscoreize ⇒ Object
43 44 45 |
# File 'lib/orchid/compiler.rb', line 43 def underscoreize return self.gsub(/\-/, '_') end |