Class: Red::DataNode::Symbol
- Inherits:
-
Red::DataNode
- Object
- String
- Red::DataNode
- Red::DataNode::Symbol
- Defined in:
- lib/red/nodes/data_nodes.rb
Overview
:nodoc:
Instance Method Summary collapse
- #camelize(string, disabled = false) ⇒ Object
- #camelize?(string) ⇒ Boolean
-
#initialize(value_data, options) ⇒ Symbol
constructor
:foo.
Methods inherited from String
#%, #*, #+, #<<, #<=>, #==, #=~, #[], #[]=, #capitalize, #capitalize!, #casecmp, #center, #chomp, #chomp!, #chop, #chop!, #concat, #count, #crypt, #delete, #delete!, #downcase, #downcase!, #each, #each_byte, #each_line, #empty?, #eql?, #gsub, #gsub!, #hash, #hex, #include?, #index, #insert, #inspect, #intern, #length, #ljust, #lstrip, #lstrip!, #match, #next, #next!, #oct, #replace, #reverse, #reverse!, #rindex, #rjust, #rstrip, #rstrip!, #scan, #size, #slice, #slice!, #split, #squeeze, #strip, #strip!, #strip_scripts, #sub, #sub!, #succ, #succ!, #sum, #swapcase, #swapcase!, #to_f, #to_i, #to_s, #to_str, #to_sym, #tr, #tr!, #tr_s, #tr_s!, #upcase, #upcase!, #upto
Constructor Details
#initialize(value_data, options) ⇒ Symbol
:foo
56 57 58 59 60 |
# File 'lib/red/nodes/data_nodes.rb', line 56 def initialize(value_data, ) value = self.camelize(value_data.to_s, [:not_camelized]) string = [:as_receiver] ? "$q(\"%s\")" : [:as_argument] ? "\"%s\"" : "%s" self << string % [value] end |
Instance Method Details
#camelize(string, disabled = false) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/red/nodes/data_nodes.rb', line 62 def camelize(string, disabled = false) return string.gsub(/@/,'').gsub('?','_bool').gsub('!','_bang').gsub('=','_eql') # return string unless self.camelize?(string) && !disabled # words = string.gsub(/@/,'').gsub('?','_bool').gsub('!','_bang').gsub('=','_eql').split(/_/) # underscore = words.shift if words.first.empty? # return (underscore ? '_' : '') + words[0] + words[1..-1].map {|word| word == word.upcase ? word : word.capitalize }.join end |
#camelize?(string) ⇒ Boolean
70 71 72 73 74 |
# File 'lib/red/nodes/data_nodes.rb', line 70 def camelize?(string) is_not_a_constant_name = string != string.upcase || string =~ (/@|\$/) is_not_a_js_special_attribute = string[0..1] != '__' return is_not_a_constant_name && is_not_a_js_special_attribute end |