Class: Shellfie::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/shellfie/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prompt: nil, command: nil, output: nil, prompt_color: nil, command_color: nil, output_color: nil, selected: false) ⇒ Line

Returns a new instance of Line.



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/shellfie/parser.rb', line 120

def initialize(prompt: nil, command: nil, output: nil, prompt_color: nil, command_color: nil, output_color: nil,
               selected: false)
  @prompt = prompt
  @command = command
  @output = output
  @prompt_color = prompt_color
  @command_color = command_color
  @output_color = output_color
  @selected = selected
  freeze
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def command
  @command
end

#command_colorObject (readonly)

Returns the value of attribute command_color.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def command_color
  @command_color
end

#outputObject (readonly)

Returns the value of attribute output.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def output
  @output
end

#output_colorObject (readonly)

Returns the value of attribute output_color.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def output_color
  @output_color
end

#promptObject (readonly)

Returns the value of attribute prompt.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def prompt
  @prompt
end

#prompt_colorObject (readonly)

Returns the value of attribute prompt_color.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def prompt_color
  @prompt_color
end

#selectedObject (readonly)

Returns the value of attribute selected.



118
119
120
# File 'lib/shellfie/parser.rb', line 118

def selected
  @selected
end

Instance Method Details

#to_hObject



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/shellfie/parser.rb', line 132

def to_h
  {
    prompt: prompt,
    command: command,
    output: output,
    prompt_color: prompt_color,
    command_color: command_color,
    output_color: output_color,
    selected: selected
  }.compact
end

#to_sObject



144
145
146
# File 'lib/shellfie/parser.rb', line 144

def to_s
  [prompt, command, output].compact.join("\n")
end