Class: Vernier::Output::Firefox::Categorizer::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/vernier/output/firefox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idx, name:, color:, matcher: nil) ⇒ Category

Returns a new instance of Category.

Raises:

  • (ArgumentError)


97
98
99
100
101
102
103
104
105
# File 'lib/vernier/output/firefox.rb', line 97

def initialize(idx, name:, color:, matcher: nil)
  raise ArgumentError, "invalid color: #{color}" if color && AVAILABLE_COLORS.none?(color)

  @idx = idx
  @name = name
  @color = color
  @matcher = matcher
  @subcategories = []
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



95
96
97
# File 'lib/vernier/output/firefox.rb', line 95

def color
  @color
end

#idxObject (readonly)

Returns the value of attribute idx.



95
96
97
# File 'lib/vernier/output/firefox.rb', line 95

def idx
  @idx
end

#matcherObject (readonly)

Returns the value of attribute matcher.



95
96
97
# File 'lib/vernier/output/firefox.rb', line 95

def matcher
  @matcher
end

#nameObject (readonly)

Returns the value of attribute name.



95
96
97
# File 'lib/vernier/output/firefox.rb', line 95

def name
  @name
end

#subcategoriesObject (readonly)

Returns the value of attribute subcategories.



95
96
97
# File 'lib/vernier/output/firefox.rb', line 95

def subcategories
  @subcategories
end

Instance Method Details

#add_subcategory(**args) ⇒ Object



107
108
109
# File 'lib/vernier/output/firefox.rb', line 107

def add_subcategory(**args)
  @subcategories << Category.new(@subcategories.size, color: nil, **args)
end

#matches?(path) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/vernier/output/firefox.rb', line 111

def matches?(path)
  @matcher && @matcher === path
end