Class: Shog::PathSet
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.make(set) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pathset.rb', line 5 def self.make(set) if set.is_a?(PathSet) set elsif set.is_a?(Path) ary = PathSet.new ary << set ary elsif set.is_a?(Array) set.map { |p| Path.make(p) } elsif set.is_a?(String) ary = PathSet.new ary << set ary else raise "Unknown path type #{set.class}" end end |
Instance Method Details
#+(ary) ⇒ Object
42 43 44 |
# File 'lib/pathset.rb', line 42 def +(ary) self.concat(PathSet.make(ary)) end |
#<<(p) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pathset.rb', line 23 def <<(p) if p.is_a?(PathSet) self.concat(p) elsif p.is_a?(Path) self.push(p) elsif p.is_a?(Array) p.each { |p| self.push(Path.make(p)) } elsif p.is_a?(String) self.push(Path.make(p)) else raise "Unknown path type #{p}" end end |
#single_path ⇒ Object
37 38 39 40 |
# File 'lib/pathset.rb', line 37 def single_path raise "Expected number of paths is 1" if self.size != 1 self[0] end |