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.



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/shellfie/parser.rb', line 181

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.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def command
  @command
end

#command_colorObject (readonly)

Returns the value of attribute command_color.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def command_color
  @command_color
end

#outputObject (readonly)

Returns the value of attribute output.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def output
  @output
end

#output_colorObject (readonly)

Returns the value of attribute output_color.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def output_color
  @output_color
end

#promptObject (readonly)

Returns the value of attribute prompt.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def prompt
  @prompt
end

#prompt_colorObject (readonly)

Returns the value of attribute prompt_color.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def prompt_color
  @prompt_color
end

#selectedObject (readonly)

Returns the value of attribute selected.



179
180
181
# File 'lib/shellfie/parser.rb', line 179

def selected
  @selected
end

Instance Method Details

#to_hObject



193
194
195
196
197
198
199
200
201
202
203
# File 'lib/shellfie/parser.rb', line 193

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



205
206
207
# File 'lib/shellfie/parser.rb', line 205

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