Class: Escort::Formatter::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/escort/formatter/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, details, setup, context) ⇒ Option

Returns a new instance of Option.



6
7
8
9
10
11
# File 'lib/escort/formatter/option.rb', line 6

def initialize(name, details, setup, context)
  @name = name.to_sym
  @details = details
  @setup = setup
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/escort/formatter/option.rb', line 4

def context
  @context
end

#detailsObject (readonly)

Returns the value of attribute details.



4
5
6
# File 'lib/escort/formatter/option.rb', line 4

def details
  @details
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/escort/formatter/option.rb', line 4

def name
  @name
end

#setupObject (readonly)

Returns the value of attribute setup.



4
5
6
# File 'lib/escort/formatter/option.rb', line 4

def setup
  @setup
end

Instance Method Details

#conflictsObject



25
26
27
# File 'lib/escort/formatter/option.rb', line 25

def conflicts
  has_conflicts? ? "conflicts with: #{conflicts_list.map{|option| "--#{option}"}.join(', ')}" : ''
end

#dependenciesObject



33
34
35
# File 'lib/escort/formatter/option.rb', line 33

def dependencies
  has_dependencies? ? "depends on: #{format_dependency_list(dependencies_list).join(', ')}" : ''
end

#descriptionObject



17
18
19
# File 'lib/escort/formatter/option.rb', line 17

def description
  [base_description_string, description_default_string].select{|item| !item.empty?}.join(" ")
end

#has_conflicts?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/escort/formatter/option.rb', line 21

def has_conflicts?
  !conflicts_list.empty?
end

#has_dependencies?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/escort/formatter/option.rb', line 29

def has_dependencies?
  !dependencies_list.empty?
end

#has_validations?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/escort/formatter/option.rb', line 37

def has_validations?
  !validations_list.empty?
end

#usageObject



13
14
15
# File 'lib/escort/formatter/option.rb', line 13

def usage
  [long_string, short_string, type_string].select{|item| !item.empty?}.join(" ")
end

#validationsObject



41
42
43
# File 'lib/escort/formatter/option.rb', line 41

def validations
  has_validations? ? validation_messages : []
end