Class: Muack::Satisfy

Inherits:
Struct
  • Object
show all
Defined in:
lib/muack/satisfy.rb

Direct Known Subclasses

Anything, HashIncluding, Including, IsA, Match, RespondTo, Conj, Disj, Within

Defined Under Namespace

Classes: Conj, Disj

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_argsObject

Returns the value of attribute api_args

Returns:

  • (Object)

    the current value of api_args



3
4
5
# File 'lib/muack/satisfy.rb', line 3

def api_args
  @api_args
end

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



3
4
5
# File 'lib/muack/satisfy.rb', line 3

def block
  @block
end

Instance Method Details

#&(rhs) ⇒ Object



9
# File 'lib/muack/satisfy.rb', line 9

def & rhs; Satisfy::Conj.new(self, rhs); end

#api_nameObject



38
39
40
41
# File 'lib/muack/satisfy.rb', line 38

def api_name
  (self.class.name || 'Unknown')[/(::)*(\w+)$/, 2].
    gsub(/([A-Z][a-z]*)+?(?=[A-Z][a-z]*)/, '\\1_').downcase
end

#match(actual_arg) ⇒ Object



4
5
6
# File 'lib/muack/satisfy.rb', line 4

def match actual_arg
  !!block.call(actual_arg)
end

#to_sObject Also known as: inspect



33
34
35
# File 'lib/muack/satisfy.rb', line 33

def to_s
  "Muack::API.#{api_name}(#{api_args.map(&:inspect).join(', ')})"
end

#|(rhs) ⇒ Object



8
# File 'lib/muack/satisfy.rb', line 8

def | rhs; Satisfy::Disj.new(self, rhs); end