Class: Fix::Subject
- Inherits:
-
Object
- Object
- Fix::Subject
- Defined in:
- lib/fix/subject.rb
Instance Attribute Summary collapse
-
#last_arg ⇒ Object
readonly
Returns the value of attribute last_arg.
Instance Method Summary collapse
- #actual ⇒ Object
- #challenge ⇒ Object
- #implemented? ⇒ Boolean
-
#initialize(input, *args) ⇒ Subject
constructor
A new instance of Subject.
- #params ⇒ Object
Constructor Details
#initialize(input, *args) ⇒ Subject
Returns a new instance of Subject.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fix/subject.rb', line 5 def initialize input, *args @args = args @error = nil @implemented = true @last_arg = -1 begin @cache_value = params.inject input do |mem, param| @implemented = mem.respond_to? param.first, false @last_arg = @last_arg.next mem.__send__(*param) end @last_arg = @last_arg.next rescue => @error end end |
Instance Attribute Details
#last_arg ⇒ Object (readonly)
Returns the value of attribute last_arg.
3 4 5 |
# File 'lib/fix/subject.rb', line 3 def last_arg @last_arg end |
Instance Method Details
#actual ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/fix/subject.rb', line 24 def actual if @error.nil? @cache_value.__send__(*challenge) else raise @error end end |
#challenge ⇒ Object
36 37 38 |
# File 'lib/fix/subject.rb', line 36 def challenge @args.last end |
#implemented? ⇒ Boolean
40 41 42 |
# File 'lib/fix/subject.rb', line 40 def implemented? @error.nil? && @implemented && @cache_value.respond_to?(challenge.first, false) end |
#params ⇒ Object
32 33 34 |
# File 'lib/fix/subject.rb', line 32 def params @args[0..-2] end |