Class: Line

Inherits:
Object
  • Object
show all
Defined in:
lib/line.rb,
lib/line/options.rb,
lib/line/version.rb,
lib/line/matchers/or.rb,
lib/line/matchers/and.rb,
lib/line/matchers/not.rb,
lib/line/matchers/index.rb,
lib/line/matchers/range.rb,
lib/line/options_parser.rb,
lib/line/matchers/helpers.rb,
lib/line/queue_with_indexes.rb,
lib/line/matchers/match_nothing.rb,
lib/line/matchers/match_everything.rb

Defined Under Namespace

Modules: Matchers Classes: OptionParser, Options, QueueWithIndexes

Constant Summary collapse

VERSION =
'1.0.1'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Line

Returns a new instance of Line.



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

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/line.rb', line 8

def options
  @options
end

Class Method Details

.call(*args) ⇒ Object



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

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/line.rb', line 14

def call
  print_matcher if options.debug?

  if options.show_help?
    print_help
    return 0
  end

  if options.errors.any?
    print_errors
    return 1
  end

  print_lines

  if unseen_indexes.any? && !options.force?
    print_unseen_indexes
    return 1
  end

  return 0
end