class SFRP::Mono::Memory
Attributes
hash[R]
Public Class Methods
empty()
click to toggle source
# File lib/sfrp/mono/memory.rb, line 4 def self.empty Memory.new end
new(hash = {})
click to toggle source
# File lib/sfrp/mono/memory.rb, line 12 def initialize(hash = {}) @hash = hash end
one(type_str)
click to toggle source
# File lib/sfrp/mono/memory.rb, line 8 def self.one(type_str) Memory.new(type_str => 1) end
Public Instance Methods
and(other)
click to toggle source
# File lib/sfrp/mono/memory.rb, line 16 def and(other) Memory.new(@hash.merge(other.hash) { |_, v1, v2| v1 + v2 }) end
count(type_str)
click to toggle source
# File lib/sfrp/mono/memory.rb, line 24 def count(type_str) @hash[type_str] || 0 end
or(other)
click to toggle source
# File lib/sfrp/mono/memory.rb, line 20 def or(other) Memory.new(@hash.merge(other.hash) { |_, v1, v2| [v1, v2].max }) end