Class: Sus::Be

Inherits:
Object
  • Object
show all
Defined in:
lib/sus/be.rb

Defined Under Namespace

Classes: And, Or

Constant Summary collapse

NIL =
Be.new(:nil?)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arguments) ⇒ Be

Returns a new instance of Be.



78
79
80
# File 'lib/sus/be.rb', line 78

def initialize(*arguments)
	@arguments = arguments
end

Class Method Details

.!=(value) ⇒ Object



119
120
121
# File 'lib/sus/be.rb', line 119

def != value
	Be.new(:!=, value)
end

.<(value) ⇒ Object



131
132
133
# File 'lib/sus/be.rb', line 131

def < value
	Be.new(:<, value)
end

.<=(value) ⇒ Object



135
136
137
# File 'lib/sus/be.rb', line 135

def <= value
	Be.new(:<=, value)
end

.==(value) ⇒ Object



115
116
117
# File 'lib/sus/be.rb', line 115

def == value
	Be.new(:==, value)
end

.===(value) ⇒ Object



143
144
145
# File 'lib/sus/be.rb', line 143

def === value
	Be.new(:===, value)
end

.=~(value) ⇒ Object



139
140
141
# File 'lib/sus/be.rb', line 139

def =~ value
	Be.new(:=~, value)
end

.>(value) ⇒ Object



123
124
125
# File 'lib/sus/be.rb', line 123

def > value
	Be.new(:>, value)
end

.>=(value) ⇒ Object



127
128
129
# File 'lib/sus/be.rb', line 127

def >= value
	Be.new(:>=, value)
end

Instance Method Details

#&(other) ⇒ Object



90
91
92
# File 'lib/sus/be.rb', line 90

def &(other)
	And.new([self, other])
end

#and(*others) ⇒ Object



94
95
96
# File 'lib/sus/be.rb', line 94

def and(*others)
	And.new([self, *others])
end

#call(assertions, subject) ⇒ Object



108
109
110
111
112
# File 'lib/sus/be.rb', line 108

def call(assertions, subject)
	assertions.nested(self) do |assertions|
		assertions.assert(subject.public_send(*@arguments))
	end
end

#or(*others) ⇒ Object



86
87
88
# File 'lib/sus/be.rb', line 86

def or(*others)
	Or.new([self, *others])
end


98
99
100
101
102
103
104
105
106
# File 'lib/sus/be.rb', line 98

def print(output)
	operation, *arguments = *@arguments
	
	output.write("be ", :be, operation.to_s, :reset)
	
	if arguments.any?
		output.write(" ", :variable, arguments.map(&:inspect).join, :reset)
	end
end

#|(other) ⇒ Object



82
83
84
# File 'lib/sus/be.rb', line 82

def |(other)
	Or.new([self, other])
end