Class: Sqrbl::HasTodos::Todo

Inherits:
Object
  • Object
show all
Defined in:
lib/sqrbl/mixins/has_todos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(message, call_stack, type)
  @message    = message
  @call_stack = call_stack
  @type       = type
end

Instance Attribute Details

#call_stackObject

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

#messageObject

Returns the value of attribute message.



9
10
11
# File 'lib/sqrbl/mixins/has_todos.rb', line 9

def message
  @message
end

#typeObject

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_lineObject

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_fileObject

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

#locationObject

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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


38
39
40
# File 'lib/sqrbl/mixins/has_todos.rb', line 38

def warning?
  type == :warning
end