class Namaste::Set
Public Class Methods
new(dir)
click to toggle source
@param [Dir] dir
# File lib/namaste/set.rb, line 4 def initialize(dir) @dir = dir end
Public Instance Methods
[](key = nil)
click to toggle source
Get only select namaste tags for the directory @return [Array<Namaste::Tag>]
# File lib/namaste/set.rb, line 16 def [] key = nil select(key) end
[]=(key, value)
click to toggle source
Set
a namaste tag @param [String] key @param [String] value
# File lib/namaste/set.rb, line 23 def []= key, value Namaste::Tag.new(@dir.path, key, value) end
all()
click to toggle source
Get all the namaste tags for the directory @return [Array<Namaste::Tag>]
# File lib/namaste/set.rb, line 10 def all select end
Private Instance Methods
select(key = nil)
click to toggle source
# File lib/namaste/set.rb, line 29 def select key = nil rgx = Namaste::PATTERN[key] if key.is_a? Symbol and Namaste::PATTERN.key?(key) rgx ||= Regexp.new("^#{Regexp.escape(key)}=") if key.is_a? String rgx ||= Regexp.new("^#{key}=") if key.is_a? Integer rgx ||= Namaste::PATTERN_EXTENDED if key == :extended rgx ||= Namaste::PATTERN_CORE if key == nil @dir.select { |x| x =~ rgx }.map { |x| Tag.new(File.join(@dir.path, x)) } end