Class: Squared::Common::JoinSet

Inherits:
Set
  • Object
show all
Defined in:
lib/squared/common/class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = [], delim: ' ') ⇒ JoinSet

Returns a new instance of JoinSet.



39
40
41
42
# File 'lib/squared/common/class.rb', line 39

def initialize(data = [], delim: ' ')
  super(data.compact)
  @delim = delim
end

Instance Attribute Details

#delimObject (readonly)

Returns the value of attribute delim.



37
38
39
# File 'lib/squared/common/class.rb', line 37

def delim
  @delim
end

Class Method Details

.to_sObject



33
34
35
# File 'lib/squared/common/class.rb', line 33

def self.to_s
  super.match(/[^:]+\z/)[0]
end

Instance Method Details

#doneObject



59
60
61
62
63
# File 'lib/squared/common/class.rb', line 59

def done
  ret = to_s
  clear
  ret
end

#pass(&blk) ⇒ Object



44
45
46
47
# File 'lib/squared/common/class.rb', line 44

def pass(&blk)
  ret = to_a.map!(&:to_s).reject(&:empty?)
  block_given? ? ret.reject(&blk) : ret
end

#temp(*args, &blk) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/squared/common/class.rb', line 49

def temp(*args, &blk)
  args.compact!
  ret = pass(&blk)
  unless args.empty?
    ret += args
    ret = Set.new(ret).to_a
  end
  ret.join(@delim)
end

#to_sObject



65
66
67
# File 'lib/squared/common/class.rb', line 65

def to_s
  pass.join(@delim)
end