Sha256: c10d8cc5815e22a9733732d52971932797fb120115a3b8ed540bab739a4ad606
Contents?: true
Size: 658 Bytes
Versions: 2
Compression:
Stored size: 658 Bytes
Contents
module Unitwise module Composable def self.included(base) base.send :include, Comparable end def composition root_terms.reduce(SignedMultiset.new) do |s, t| s.increment(t.atom.dim, t.exponent) if t.atom; s end end def dim composition_string end def composition_string composition.sort.map do |k,v| v == 1 ? k.to_s : "#{k}#{v}" end.join('.') end def similar_to?(other) self.composition == other.composition end def <=>(other) if other.respond_to?(:composition) && similar_to?(other) scalar <=> other.scalar end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unitwise-0.3.0 | lib/unitwise/composable.rb |
unitwise-0.2.2 | lib/unitwise/composable.rb |