Class: Reviewer::Arguments::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/arguments/tags.rb

Overview

Handles the logic of translating tag arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provided: [], keywords: []) ⇒ self

Generates an instance of parsed tags from the provided arguments by merging tag arguments

that were provided via either flags or keywords

Examples:

Using keywords: ‘rvw ruby` (assuming a ’ruby’ tag is defined)

Reviewer::Arguments::Tags.new.to_a # => ['ruby']

Using the -t flag: ‘rvw -t ruby`

Reviewer::Arguments::Tags.new.to_a # => ['ruby']

Using the --tags flag: ‘rvw -t ruby,css`

Reviewer::Arguments::Tags.new.to_a # => ['css', 'ruby']


30
31
32
33
# File 'lib/reviewer/arguments/tags.rb', line 30

def initialize(provided: [], keywords: [])
  @provided = Array(provided)
  @keywords = Array(keywords)
end

Instance Attribute Details

#keywordsObject

Returns the value of attribute keywords.



11
# File 'lib/reviewer/arguments/tags.rb', line 11

attr_reader :provided, :keywords

#providedArray<String> Also known as: raw



11
12
13
# File 'lib/reviewer/arguments/tags.rb', line 11

def provided
  @provided
end

Instance Method Details

#to_aArray<String>

Provides the full list of tags values derived from the command-line arguments



38
# File 'lib/reviewer/arguments/tags.rb', line 38

def to_a = tag_list

#to_hHash Also known as: inspect

Summary of the state of the tag arguments



48
49
50
51
52
53
# File 'lib/reviewer/arguments/tags.rb', line 48

def to_h
  {
    provided: provided.sort,
    from_keywords: keywords.sort
  }
end

#to_sString

Provides the full list of tag values derived from the command-line arguments



43
# File 'lib/reviewer/arguments/tags.rb', line 43

def to_s = to_a.join(',')