Class: NA::Project

Inherits:
Hash
  • Object
show all
Defined in:
lib/na/project.rb

Overview

Represents a project section in a todo file, with indentation and line tracking.

Examples:

Create a new project

project = NA::Project.new('Inbox', 0, 1, 5)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#deep_freeze, #deep_freeze!, #deep_merge, #deep_thaw, #deep_thaw!, #symbolize_keys

Constructor Details

#initialize(project, indent = 0, line = 0, last_line = 0) ⇒ void

Initialize a Project object

Examples:

project = NA::Project.new('Inbox', 0, 1, 5)

Parameters:

  • project (String)

    Project name

  • indent (Integer) (defaults to: 0)

    Indentation level

  • line (Integer) (defaults to: 0)

    Starting line number

  • last_line (Integer) (defaults to: 0)

    Ending line number



20
21
22
23
24
25
26
# File 'lib/na/project.rb', line 20

def initialize(project, indent = 0, line = 0, last_line = 0)
  super()
  @project = project
  @indent = indent
  @line = line
  @last_line = last_line
end

Instance Attribute Details

#indentObject

Returns the value of attribute indent.



9
10
11
# File 'lib/na/project.rb', line 9

def indent
  @indent
end

#last_lineObject

Returns the value of attribute last_line.



9
10
11
# File 'lib/na/project.rb', line 9

def last_line
  @last_line
end

#lineObject

Returns the value of attribute line.



9
10
11
# File 'lib/na/project.rb', line 9

def line
  @line
end

#projectObject

Returns the value of attribute project.



9
10
11
# File 'lib/na/project.rb', line 9

def project
  @project
end

Instance Method Details

#inspectString

Inspect the project object

Returns:



40
41
42
43
44
45
46
47
# File 'lib/na/project.rb', line 40

def inspect
  [
    "@project: #{@project}",
    "@indent: #{@indent}",
    "@line: #{@line}",
    "@last_line: #{@last_line}"
  ].join(' ')
end

#to_sString

String representation of the project

Examples:

project.to_s #=> "{ project: 'Inbox', ... }"

Returns:



33
34
35
# File 'lib/na/project.rb', line 33

def to_s
  { project: @project, indent: @indent, line: @line, last_line: @last_line }.to_s
end