Module: Checked::DSL::Racked
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Ruby
#array!, #array?, #bool!, #dont_print_specs, #fail!, #false!, #hash!, #hash?, #keys!, #not_empty!, #respond_to_all?, #spec, #spec!, #string!, #string?, #true!
Class Method Details
153
154
155
156
157
158
159
160
|
# File 'lib/Checked/DSL.rb', line 153
def self.eval! m
caller(1).first =~ %r!([^\:]+):(\d+):in `.!
if $1 && $2
eval m, nil, $1, $2.to_i - m.split("\n").size + 1
else
eval m, nil
end
end
|
Instance Method Details
#demand(*pars) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/Checked/DSL.rb', line 138
def demand *pars
if pars.size == 2
val = return!
bool, raw_msg = pars
elsif respond_to?(:return!) && return! == pars[0]
val, bool, raw_msg = pars
else
return super
end
msg = raw_msg.sub(%r!\A\.\.\.!, "#{target_name || return!.class}, #{return!.inspect}, ")
super( return!, bool, msg )
end
|
#Size!(arg, num_or_range) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/Checked/DSL.rb', line 180
def Size! arg, num_or_range
sizes = case num_or_range
when Fixnum
[num_or_range]
when Range
num_or_range.to_a
else
raise ArgumentError, "Wrong class for size: #{num_or_range.inspect}"
end
if not sizes.include?(arg.size)
raise ArgumentError, "Array, #{arg.inspect}, can only contain #{sizes.join ' or '} items."
end
arg
end
|
#Stripped!(*args) ⇒ Object
173
174
175
176
177
178
|
# File 'lib/Checked/DSL.rb', line 173
def Stripped! *args
v = String!(*args)
n = v.strip
n.Checked= v.Checked
n
end
|