Class: ScriptLine

Inherits:
Object
  • Object
show all
Defined in:
lib/shell/script_line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(l) ⇒ ScriptLine

Returns a new instance of ScriptLine.



4
5
6
7
8
# File 'lib/shell/script_line.rb', line 4

def initialize(l)
  @line = l.strip
  @words = l.split(/[ \t]+/)
  @clean_words = @words.map{|w| CommandWord.clean(w) }
end

Instance Attribute Details

#clean_wordsObject

Returns the value of attribute clean_words.



2
3
4
# File 'lib/shell/script_line.rb', line 2

def clean_words
  @clean_words
end

#lineObject

Returns the value of attribute line.



2
3
4
# File 'lib/shell/script_line.rb', line 2

def line
  @line
end

#wordsObject

Returns the value of attribute words.



2
3
4
# File 'lib/shell/script_line.rb', line 2

def words
  @words
end

Instance Method Details

#commandObject



10
11
12
# File 'lib/shell/script_line.rb', line 10

def command
  clean_words.first
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/shell/script_line.rb', line 14

def valid?
  !(comment? || empty?)
end