Class: RBelly::BELLEJS::Class

Inherits:
Base
  • Object
show all
Defined in:
lib/rbelly/bellejs/class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body = nil) ⇒ Class

Returns a new instance of Class.



19
20
21
22
23
# File 'lib/rbelly/bellejs/class.rb', line 19

def initialize(body = nil)
  super()
  @body = body
  self['toString'] = :undefined
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



18
19
20
# File 'lib/rbelly/bellejs/class.rb', line 18

def body
  @body
end

Class Method Details

.create(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rbelly/bellejs/class.rb', line 5

def create(*args)
  if args.length > 0
    parser = RBelly::Parser.new
    body = args.pop
    tree = parser.parse("class { #{body} }")
    klass = tree.value.first
    self.new(klass.class_body)
  else
    self.new
  end
end