Module: RedGrape::Tools::IRG::Help
- Defined in:
- lib/red_grape/tools/irg.rb
Class Method Summary collapse
- .camelcase(str) ⇒ Object
- .help_message ⇒ Object
- .pipe_help_message ⇒ Object
- .redgrape?(key = nil) ⇒ Boolean
- .underscore(str) ⇒ Object
Class Method Details
.camelcase(str) ⇒ Object
44 45 46 |
# File 'lib/red_grape/tools/irg.rb', line 44 def camelcase(str) str.sub(/^[a-z]/){|p| p.upcase}.gsub(/_([a-z])/){"#{$1.upcase}"} end |
.help_message ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/red_grape/tools/irg.rb', line 26 def "Subcommands:\n redgrape? :pipe : list all pipes.\n EOS\n #redgrape? '[pipe name]' : describe the given pipe.\nend\n" |
.pipe_help_message ⇒ Object
34 35 36 37 38 |
# File 'lib/red_grape/tools/irg.rb', line 34 def pipes = RedGrape::Pipe.constants.map(&:to_s).select{|p| p =~ /.*Pipe$/}.map{|p| underscore p.sub(/Pipe$/, '')} "Available pipes:\n #{pipes.sort.join ', '}" end |
.redgrape?(key = nil) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/red_grape/tools/irg.rb', line 12 def redgrape?(key=nil) case key when NilClass puts :OK when 'pipe', 'pipes', :pipe, :pieps puts :OK else puts '?' :NG end end |
.underscore(str) ⇒ Object
40 41 42 |
# File 'lib/red_grape/tools/irg.rb', line 40 def underscore(str) str.sub(/^[A-Z]/){|p| p.downcase}.gsub(/([a-z])([A-Z])/){"#{$1}_#{$2.downcase}"} end |