Class: MarkdownExec::LinkState

Inherits:
Object
  • Object
show all
Defined in:
lib/link_history.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block_name: nil, display_menu: nil, document_filename: nil, inherited_block_names: [], inherited_dependencies: nil, inherited_lines: nil, keep_code: false, prior_block_was_link: nil) ⇒ LinkState

Initialize the LinkState with keyword arguments for each attribute.

Parameters:

  • block_name (String, nil) (defaults to: nil)

    the name of the block.

  • document_filename (String, nil) (defaults to: nil)

    the filename of the document.

  • inherited_block_names (Array<String>, nil) (defaults to: [])

    the names of the inherited blocks.

  • inherited_dependencies (?, nil) (defaults to: nil)

    the dependecy hierarcy.

  • inherited_lines (Array<String>, nil) (defaults to: nil)

    the inherited lines of code.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/link_history.rb', line 20

def initialize(block_name: nil, display_menu: nil, document_filename: nil,
               inherited_block_names: [], inherited_dependencies: nil, inherited_lines: nil,
               keep_code: false, prior_block_was_link: nil)
  @block_name = block_name
  @display_menu = display_menu
  @document_filename = document_filename
  @inherited_block_names = inherited_block_names
  @inherited_dependencies = inherited_dependencies
  @inherited_lines = inherited_lines
  @keep_code = keep_code
  @prior_block_was_link = prior_block_was_link
end

Instance Attribute Details

#block_nameObject

Returns the value of attribute block_name.



10
11
12
# File 'lib/link_history.rb', line 10

def block_name
  @block_name
end

#display_menuObject

Returns the value of attribute display_menu.



10
11
12
# File 'lib/link_history.rb', line 10

def display_menu
  @display_menu
end

#document_filenameObject

Returns the value of attribute document_filename.



10
11
12
# File 'lib/link_history.rb', line 10

def document_filename
  @document_filename
end

#inherited_block_namesObject

Returns the value of attribute inherited_block_names.



10
11
12
# File 'lib/link_history.rb', line 10

def inherited_block_names
  @inherited_block_names
end

#inherited_dependenciesObject

Returns the value of attribute inherited_dependencies.



10
11
12
# File 'lib/link_history.rb', line 10

def inherited_dependencies
  @inherited_dependencies
end

#keep_codeObject

Returns the value of attribute keep_code.



10
11
12
# File 'lib/link_history.rb', line 10

def keep_code
  @keep_code
end

Returns the value of attribute prior_block_was_link.



10
11
12
# File 'lib/link_history.rb', line 10

def prior_block_was_link
  @prior_block_was_link
end

Class Method Details

.emptyLinkState

Creates an empty LinkState instance.

Returns:

  • (LinkState)

    an instance with all attributes set to their default values.



35
36
37
# File 'lib/link_history.rb', line 35

def self.empty
  new
end

Instance Method Details

#==(other) ⇒ Boolean

Custom equality method to compare LinkState objects.

Parameters:

  • other (LinkState)

    the other LinkState object to compare with.

Returns:

  • (Boolean)

    true if the objects are equal, false otherwise.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/link_history.rb', line 42

def ==(other)
  other.class == self.class &&
    other.block_name == block_name &&
    other.display_menu == display_menu &&
    other.document_filename == document_filename &&
    other.inherited_block_names == inherited_block_names &&
    other.inherited_dependencies == inherited_dependencies &&
    other.inherited_lines == inherited_lines &&
    other.keep_code == keep_code &&
    other.prior_block_was_link == prior_block_was_link
end

#inherited_linesObject



54
55
56
57
58
# File 'lib/link_history.rb', line 54

def inherited_lines
  @inherited_lines.tap { |ret|
    pp ['LinkState.inherited_lines() ->', ret] if $pd
  }
end

#inherited_lines=(value) ⇒ Object



60
61
62
63
64
# File 'lib/link_history.rb', line 60

def inherited_lines=(value)
  @inherited_lines = value.tap { |ret|
    pp ['LinkState.inherited_lines=() ->', ret] if $pd
  }
end

#inherited_lines_append(value) ⇒ Object



66
67
68
69
70
# File 'lib/link_history.rb', line 66

def inherited_lines_append(value)
  @inherited_lines = ((@inherited_lines || []) + value).tap { |ret|
    pp ['LinkState.inherited_lines_append() ->', ret] if $pd
  }
end

#inherited_lines_blockObject



72
73
74
75
76
# File 'lib/link_history.rb', line 72

def inherited_lines_block
  (@inherited_lines || []).join("\n").tap { |ret|
    pp ['LinkState.inherited_lines_block() ->', ret] if $pd
  }
end

#inherited_lines_countObject



78
79
80
81
82
# File 'lib/link_history.rb', line 78

def inherited_lines_count
  (@inherited_lines&.count || 0).tap { |ret|
    pp ['LinkState.inherited_lines_count() ->', ret] if $pd
  }
end

#inherited_lines_mapObject



84
85
86
87
88
# File 'lib/link_history.rb', line 84

def inherited_lines_map
  @inherited_lines.map do |line|
    yield line
  end.tap { |ret| pp ['LinkState.inherited_lines_map() ->', ret] if $pd }
end

#inherited_lines_present?Boolean

Returns:

  • (Boolean)


90
91
92
93
94
# File 'lib/link_history.rb', line 90

def inherited_lines_present?
  @inherited_lines.present?.tap { |ret|
    pp ['LinkState.inherited_lines_present?() ->', ret] if $pd
  }
end