Class: Sqrbl::HasTodos::Todo
Instance Attribute Summary collapse
-
#call_stack ⇒ Object
Returns the value of attribute call_stack.
-
#message ⇒ Object
Returns the value of attribute message.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#calling_line ⇒ Object
Return just the line number from
location
. -
#creating_file ⇒ Object
Return just the filename from
location
. -
#initialize(message, call_stack, type) ⇒ Todo
constructor
A new instance of Todo.
-
#location ⇒ Object
Returns the first item from the call stack that isn’t inside the Sqrbl library.
-
#todo? ⇒ Boolean
Is this Todo of type
:todo
?. -
#warning? ⇒ Boolean
Is this Todo of type
:warning
?.
Constructor Details
#initialize(message, call_stack, type) ⇒ Todo
Returns a new instance of Todo.
10 11 12 13 14 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 10 def initialize(, call_stack, type) @message = @call_stack = call_stack @type = type end |
Instance Attribute Details
#call_stack ⇒ Object
Returns the value of attribute call_stack.
9 10 11 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 9 def call_stack @call_stack end |
#message ⇒ Object
Returns the value of attribute message.
9 10 11 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 9 def @message end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 9 def type @type end |
Instance Method Details
#calling_line ⇒ Object
Return just the line number from location
.
23 24 25 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 23 def calling_line CallStack.caller_line(location) end |
#creating_file ⇒ Object
Return just the filename from location
.
28 29 30 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 28 def creating_file CallStack.caller_file(location) end |
#location ⇒ Object
Returns the first item from the call stack that isn’t inside the Sqrbl library. This lets us output a pointer back to the place where this instance was created.
18 19 20 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 18 def location @location ||= call_stack.detect { |call| ! call.include?(Sqrbl::LIBPATH) } end |
#todo? ⇒ Boolean
Is this Todo of type :todo
?
33 34 35 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 33 def todo? type == :todo end |
#warning? ⇒ Boolean
Is this Todo of type :warning
?
38 39 40 |
# File 'lib/sqrbl/mixins/has_todos.rb', line 38 def warning? type == :warning end |