Method: Entityjs::Compile.to_entity

Defined in:
lib/entityjs/compile.rb

.to_entity(comps, json) ⇒ Object

converts given comps and json into an entityjs entity returns an entityjs component



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/entityjs/compile.rb', line 90

def self.to_entity(comps, json)
  
  #remove plurals
  comps.collect! do |i|
    
    #115 for ruby 1.8.7
    if i[-1] == 's' || i[-1] == 115
      i[0..-2]
    else
      i
    end
    
  end
  
  #turn into one long strng
  comps = comps.join(' ')
  
  #output entity
  return "re.e('#{comps}')\n.attr(#{json})"
end