Module: Jury::Tchk
- Included in:
- CommandLineInterface
- Defined in:
- lib/jury/tchk.rb
Instance Method Summary collapse
- #is_array_of_T(ary, type = nil, minimum_length = 0) ⇒ Object
- #is_string(s) ⇒ Object
- #type_error ⇒ Object
Instance Method Details
#is_array_of_T(ary, type = nil, minimum_length = 0) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jury/tchk.rb', line 11 def is_array_of_T(ary, type = nil, minimum_length = 0) is_an_array = ary.kind_of?(Array) if !type.nil? then type_error if !type.kind_of?(Class) all_elements_of_type = ary.all? { |e| e.kind_of?(type) } else all_elements_of_type = true end minimum_length_met = ary.size >= minimum_length return is_an_array && all_elements_of_type && minimum_length_met end |
#is_string(s) ⇒ Object
7 8 9 |
# File 'lib/jury/tchk.rb', line 7 def is_string(s) return s.kind_of?(String) end |
#type_error ⇒ Object
3 4 5 |
# File 'lib/jury/tchk.rb', line 3 def type_error raise Exception.new, "Type error" end |