Class: Grumlin::Shortcut

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/grumlin/shortcut.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, lazy: true, &block) ⇒ Shortcut

Returns a new instance of Shortcut.



11
12
13
14
15
# File 'lib/grumlin/shortcut.rb', line 11

def initialize(name, lazy: true, &block)
  @name = name
  @lazy = lazy
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/grumlin/shortcut.rb', line 6

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/grumlin/shortcut.rb', line 6

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/grumlin/shortcut.rb', line 17

def ==(other)
  @name == other.name && @block == other.block
end

#apply(object, *args, **params) ⇒ Object

TODO: to_s, inspect, preview



27
28
29
# File 'lib/grumlin/shortcut.rb', line 27

def apply(object, *args, **params)
  object.instance_exec(*args, **params, &@block)
end

#lazy?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/grumlin/shortcut.rb', line 21

def lazy?
  @lazy
end