Class: Numerals::FormattingAspect

Inherits:
Object
  • Object
show all
Defined in:
lib/numerals/formatting_aspect.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](*args) ⇒ Object



9
10
11
# File 'lib/numerals/formatting_aspect.rb', line 9

def self.[](*args)
  new *args
end

.aspect(aspect, &blk) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/numerals/formatting_aspect.rb', line 17

def self.aspect(aspect, &blk)
  define_method :"set_#{aspect}!" do |*args|
    instance_exec(*args, &blk)
    self
  end
  define_method :"set_#{aspect}" do |*args|
    dup.send(:"set_#{aspect}!", *args)
  end
end

.set(*args, &blk) ⇒ Object



27
28
29
30
31
32
# File 'lib/numerals/formatting_aspect.rb', line 27

def self.set(*args, &blk)
  define_method :"set!" do |*args|
    instance_exec(*args, &blk)
    self
  end
end

Instance Method Details

#[](*args) ⇒ Object



5
6
7
# File 'lib/numerals/formatting_aspect.rb', line 5

def [](*args)
  set *args
end

#set(*args) ⇒ Object



13
14
15
# File 'lib/numerals/formatting_aspect.rb', line 13

def set(*args)
  dup.set! *args
end