Class: Code::Object::Range
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Range
- Defined in:
- lib/code/object/range.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #call(**args) ⇒ Object
-
#initialize(left, right, exclude_end: false) ⇒ Range
constructor
A new instance of Range.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods inherited from Code::Object
#<=>, #==, #[], #[]=, #falsy?, #hash, #key?, #truthy?
Constructor Details
#initialize(left, right, exclude_end: false) ⇒ Range
Returns a new instance of Range.
6 7 8 9 10 11 |
# File 'lib/code/object/range.rb', line 6 def initialize(left, right, exclude_end: false) @left = left @right = right @exclude_end = exclude_end @raw = ::Range.new(left, right, exclude_end) end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/code/object/range.rb', line 4 def raw @raw end |
Instance Method Details
#call(**args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/code/object/range.rb', line 13 def call(**args) operator = args.fetch(:operator, nil) arguments = args.fetch(:arguments, []) context = args.fetch(:context) io = args.fetch(:io) if operator == "any?" any?(arguments, context: context, io: io) elsif operator == "all?" all?(arguments, context: context, io: io) elsif operator == "each" each(arguments, context: context, io: io) elsif operator == "select" select(arguments, context: context, io: io) elsif operator == "map" map(arguments, context: context, io: io) elsif operator == "step" step(arguments) elsif operator == "to_list" to_list(arguments) elsif operator == "first" first(arguments) elsif operator == "last" last(arguments) else super end end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/code/object/range.rb', line 46 def inspect to_s end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/code/object/range.rb', line 42 def to_s raw.to_s end |