Class: Squared::Common::JoinSet
- Inherits:
-
Set
- Object
- Set
- Squared::Common::JoinSet
- Defined in:
- lib/squared/common/class.rb
Instance Attribute Summary collapse
-
#delim ⇒ Object
readonly
Returns the value of attribute delim.
Class Method Summary collapse
Instance Method Summary collapse
- #done ⇒ Object
-
#initialize(data = [], delim: ' ') ⇒ JoinSet
constructor
A new instance of JoinSet.
- #pass(&blk) ⇒ Object
- #temp(*args, &blk) ⇒ Object
- #to_s ⇒ Object
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
#delim ⇒ Object (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_s ⇒ Object
33 34 35 |
# File 'lib/squared/common/class.rb', line 33 def self.to_s super.match(/[^:]+\z/)[0] end |
Instance Method Details
#done ⇒ Object
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_s ⇒ Object
65 66 67 |
# File 'lib/squared/common/class.rb', line 65 def to_s pass.join(@delim) end |