Module: Kwatable::RubyHelper

Defined in:
lib/kwatable/template/helper/ruby.rb

Constant Summary collapse

@@ruby_keyword_table =
ruby_keywords().inject({}) { |h, w| h[w] = true; h }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ruby_keywordsObject

ruby keywords



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kwatable/template/helper/ruby.rb', line 13

def self.ruby_keywords()
  keywords = <<-END
     BEGIN END alias and begin break case
     class def defined do else elsif end
     ensure false for if in module next
     nil not or redo rescue retry return
     self super then true undef unless
     until when while yield
  END
  return keywords.split(/\s+/)
end

Instance Method Details

#escape_ruby_keyword(word) ⇒ Object

escape ruby keywords



29
30
31
# File 'lib/kwatable/template/helper/ruby.rb', line 29

def escape_ruby_keyword(word)
  return @@ruby_keyword_table[word] ? "_#{word}" : word
end