class EDTF::Uncertainty
TODO use bitmasks instead of arrays
Attributes
hash_base[R]
Public Class Methods
new(year = nil, month = nil, day = nil, hash_base = 1)
click to toggle source
Calls superclass method
# File lib/edtf/uncertainty.rb 9 def initialize(year = nil, month = nil, day = nil, hash_base = 1) 10 @hash_base = hash_base 11 super(year, month, day) 12 end
Public Instance Methods
certain!(parts = members)
click to toggle source
# File lib/edtf/uncertainty.rb 30 def certain!(parts = members) 31 [*parts].each { |p| send("#{p}=", false) } 32 self 33 end
certain?(parts = members)
click to toggle source
# File lib/edtf/uncertainty.rb 28 def certain?(parts = members); !uncertain?(parts); end
eql?(other)
click to toggle source
# File lib/edtf/uncertainty.rb 35 def eql?(other) 36 hash == other.hash 37 end
hash()
click to toggle source
# File lib/edtf/uncertainty.rb 39 def hash 40 values.zip(hash_map).reduce(0) { |s, (v, h)| s + (v ? h : 0) } 41 end
hash_base=(base)
click to toggle source
# File lib/edtf/uncertainty.rb 14 def hash_base=(base) 15 @hash_map = false 16 @hash_base = base 17 end
uncertain!(parts = members)
click to toggle source
# File lib/edtf/uncertainty.rb 23 def uncertain!(parts = members) 24 [*parts].each { |p| send("#{p}=", true) } 25 self 26 end
uncertain?(parts = members)
click to toggle source
# File lib/edtf/uncertainty.rb 19 def uncertain?(parts = members) 20 [*parts].any? { |p| !!send(p) } 21 end
Private Instance Methods
hash_map()
click to toggle source
# File lib/edtf/uncertainty.rb 45 def hash_map 46 @hash_map ||= (0...length).map { |i| hash_base << i } 47 end