Class: Hivemind::UniversalAST::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/hivemind/universal_ast.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fields(*labels) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/hivemind/universal_ast.rb', line 4

def self.fields(*labels)
  define_method(:initialize) do |*args|
    args.zip(labels).each do |arg, label|
      instance_variable_set "@#{label}", arg
    end
  end
  attr_reader *labels
end

Instance Method Details

#offset(depth) ⇒ Object



13
14
15
# File 'lib/hivemind/universal_ast.rb', line 13

def offset(depth)
  '    ' * depth
end