Class: Opal::Nodes::NodeWithArgs::Shortcut

Inherits:
Struct
  • Object
show all
Defined in:
lib/opal/nodes/node_with_args/shortcuts.rb

Overview

Shortcuts for the simplest kinds of methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#forObject

Returns the value of attribute for

Returns:

  • (Object)

    the current value of for



7
8
9
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 7

def for
  @for
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 7

def name
  @name
end

#transformObject

Returns the value of attribute transform

Returns:

  • (Object)

    the current value of transform



7
8
9
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 7

def transform
  @transform
end

#whenObject

Returns the value of attribute when

Returns:

  • (Object)

    the current value of when



7
8
9
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 7

def when
  @when
end

Instance Method Details

#compile(node) ⇒ Object



12
13
14
15
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 12

def compile(node)
  node.helper name
  node.instance_exec(&transform)
end

#match?(node) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/opal/nodes/node_with_args/shortcuts.rb', line 8

def match?(node)
  node.instance_exec(&self.when)
end