Class: Nilish

Inherits:
Object show all
Defined in:
lib/shorthand.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &b) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/shorthand.rb', line 17

def method_missing(m,*a,&b)
  case
  when nil.respond_to?(m)   then nil.send(m,*a,&b)
  when false.respond_to?(m) then false.send(m,*a,&b)
  when m.to_s[-1..-1]=='?'  then nil
  else self end
end

Class Method Details

.globalObject



10
# File 'lib/shorthand.rb', line 10

def self.global()$__N||= self.new end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


13
# File 'lib/shorthand.rb', line 13

def blank?()     true             end

#empty?Boolean

Returns:

  • (Boolean)


15
# File 'lib/shorthand.rb', line 15

def empty?()     true             end

#inspectObject



11
# File 'lib/shorthand.rb', line 11

def inspect()    "nil(ish)"       end

#nil?Boolean

Returns:

  • (Boolean)


14
# File 'lib/shorthand.rb', line 14

def nil?()       true             end

#to_strObject



12
# File 'lib/shorthand.rb', line 12

def to_str()     ''               end

#wrap(*args) ⇒ Object



16
# File 'lib/shorthand.rb', line 16

def wrap(*args)  ''               end