Class: Vue
- Inherits:
-
Object
- Object
- Vue
- Defined in:
- lib/vue.rb
Overview
“@ … @” for js_variable
"# ... #" for js_function
": ... :" for html_code
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#value ⇒ Object
Returns the value of attribute value.
-
#value_property ⇒ Object
Returns the value of attribute value_property.
Instance Method Summary collapse
-
#add_components(components_name, components) ⇒ Object
“components,”@name@“=>{”@template@“=>”:<h1>…<h1>:“}”.
-
#add_methods(methods_block_name, js_method) ⇒ Object
“name:function()…”.
- #apply ⇒ Object
-
#initialize(hash) ⇒ Vue
constructor
传入hash,被转换成js object 后进行eval 用法 whatever,×,‘name:function,*` 目前基于eval实现性能堪忧.
Constructor Details
#initialize(hash) ⇒ Vue
传入hash,被转换成js object 后进行eval 用法 whatever,×,‘name:function,*` 目前基于eval实现性能堪忧
13 14 15 16 17 18 19 20 |
# File 'lib/vue.rb', line 13 def initialize(hash) @value_property = hash @value = hash.to_s.gsub(/=>/,":").gsub(/\"@/,"").gsub(/@\"/,"") #debug puts self.value @prefix = "`new Vue(" @suffix = ")`" end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/vue.rb', line 8 def error @error end |
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/vue.rb', line 8 def prefix @prefix end |
#suffix ⇒ Object
Returns the value of attribute suffix.
8 9 10 |
# File 'lib/vue.rb', line 8 def suffix @suffix end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/vue.rb', line 8 def value @value end |
#value_property ⇒ Object
Returns the value of attribute value_property.
8 9 10 |
# File 'lib/vue.rb', line 8 def value_property @value_property end |
Instance Method Details
#add_components(components_name, components) ⇒ Object
“components,”@name@“=>{”@template@“=>”:<h1>…<h1>:“}”
44 45 46 47 48 49 50 51 |
# File 'lib/vue.rb', line 44 def add_components(components_name,components) self.value = self.value.chomp("}") tmp = ","+components_name+":"+components.to_s.gsub(/\":/,"\"").gsub(/:\"/,"\"").gsub(/=>/,":").gsub(/\"@/,"").gsub(/@\"/,"") + "}" puts tmp self.value += tmp #debug puts self.value end |
#add_methods(methods_block_name, js_method) ⇒ Object
“name:function()…”
23 24 25 26 27 28 29 30 31 |
# File 'lib/vue.rb', line 23 def add_methods(methods_block_name,js_method) self.value = self.value.chomp("}") tmp = ","+methods_block_name+":"+js_method.to_s.gsub(/=>/,":").gsub(/\"@/,"").gsub(/@\"/,"").gsub(/\"#/,"").gsub(/#\"/,"") + "}" puts tmp self.value += tmp #debug puts self.value end |
#apply ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/vue.rb', line 54 def apply() source = self.prefix + self.value.gsub(/\\n/,"") + self.suffix #debug puts source return eval(source) puts "Error How did you get here????" end |