Module: Positify
- Defined in:
- lib/positify.rb,
lib/positify/version.rb
Defined Under Namespace
Modules: VERSION
Class Method Summary collapse
Class Method Details
.it(*args, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/positify.rb', line 5 def self.it(*args, &block) if block_given? raise(ArgumentError, "You can only pass in one options Hash in block mode, not #{args.inspect}") if args.size > 1 object = block.call = args.shift || {} else case args.size when 1 object = args.shift = {} raise(ArgumentError, "You forgot the brackets in your call. Try: Positify::it(...) do") if object.is_a?(Hash) when 2 object = args.shift = args.shift else raise ArgumentError, "You must pass in an object and may pass in an options Hash, not #{args.inspect}" end end [:max] = it([:max]) if [:max] return 1 unless object.respond_to?(:to_i) result = object.to_i.abs > 0 ? object.to_i.abs : 1 result = [:max] if [:max] && [:max] < result result end |