nyaplot
nyaplot copied to clipboard
Four arithmetic operations
I defined four arithmetic operations (+, -, *, /) of Nyaplot::Series.
These operators work like this:
series = Nyaplot::Series.new(:series, [10,20])
another_series = Nyaplot::Series.new(:another_series, [30, 40])
scalar = 10
# addition
series + another_series # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[40, 60], @label=:series>
series + scalar # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[20, 30], @label=:series>
# subtraction
series - another_series # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[-20, -20], @label=:series>
series - scalar # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[0, 10], @label=:series>
# multiplication
series * another_series # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[300, 800], @label=:series>
series * scalar # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[100, 200], @label=:series>
# division
series / another_series # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[0, 0], @label=:series>
series / scalar # => <Nyaplot::Series:0x00561200fa5fb0 @arr=[1, 2], @label=:series>