Sha256: 5c8c135d01461152f2ab64db3bd8e3480dd116c85ff90530c33b074570df64b6
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
require 'gobstones/lang/literals/literal' module Gobstones module Lang class Number < Literal attr_reader :value def initialize(num) @value = num end def == other super(other) && value == other.value end def <(other) value < other.value end def return_type :Number end [:+, :-, :*, :/, :%, :**].each do |selector| define_method selector do |other| self.class.new value.send(selector, other.value) end end def opposite self.class.new(-value) end def previous self.class.new(value - 1) end def next self.class.new(value + 1) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gobstones-0.0.1.1 | lib/gobstones/lang/literals/number.rb |