Class: Matrixeval::Context::FindByCommandOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/matrixeval/context/find_by_command_options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FindByCommandOptions

Returns a new instance of FindByCommandOptions.



12
13
14
# File 'lib/matrixeval/context/find_by_command_options.rb', line 12

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.call(options) ⇒ Object



5
6
7
# File 'lib/matrixeval/context/find_by_command_options.rb', line 5

def call(options)
  new(options).call
end

Instance Method Details

#callObject

Raises:



16
17
18
19
20
21
22
23
24
25
# File 'lib/matrixeval/context/find_by_command_options.rb', line 16

def call
  context = Context.all.find do |context|
    context.main_variant == main_variant &&
      context.rest_variants == rest_variants
  end

  raise Error.new("Can't find a corresponding matrix") if context.nil?

  context
end