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, context_code: nil, keep_code: false, prior_block_was_link: nil) ⇒ LinkState

Initialize the LinkState with keyword arguments for each attribute. the inherited blocks.

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

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

    the dependecy hierarcy.

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

    the context code (shell code that provides the necessary code and data for the evaluation of individual blocks).

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

    Deprecated: Use context_code instead.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/link_history.rb', line 23

def initialize(
  block_name: nil, display_menu: nil, document_filename: nil,
  inherited_block_names: [], inherited_dependencies: nil,
  context_code: 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
  # Support both new and deprecated parameter names
  @context_code = context_code
  @keep_code = keep_code
  @prior_block_was_link = prior_block_was_link
  wwt :link_state, self, caller.deref
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. set to their default values.

Returns:

  • (LinkState)

    an instance with all attributes



43
44
45
# File 'lib/link_history.rb', line 43

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.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/link_history.rb', line 50

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.context_code == context_code &&
    other.keep_code == keep_code &&
    other.prior_block_was_link == prior_block_was_link
end

#context_codeObject



62
63
64
65
66
# File 'lib/link_history.rb', line 62

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

#context_code=(value) ⇒ Object



68
69
70
71
72
# File 'lib/link_history.rb', line 68

def context_code=(value)
  @context_code = value.tap do |ret|
    pp ['LinkState.context_code=() ->', ret, caller.deref(3).last] if $pd
  end
end

#context_code_append(value) ⇒ Object



74
75
76
77
78
# File 'lib/link_history.rb', line 74

def context_code_append(value)
  @context_code = ((@context_code || []) + value).tap do |ret|
    pp ['LinkState.context_code_append() ->', ret] if $pd
  end
end

#context_code_blockObject



80
81
82
83
84
# File 'lib/link_history.rb', line 80

def context_code_block
  (@context_code || []).join("\n").tap do |ret|
    pp ['LinkState.context_code_block() ->', ret] if $pd
  end
end

#context_code_countObject



86
87
88
89
90
# File 'lib/link_history.rb', line 86

def context_code_count
  (@context_code&.count || 0).tap do |ret|
    pp ['LinkState.context_code_count() ->', ret] if $pd
  end
end

#context_code_map(&block) ⇒ Object



92
93
94
95
96
# File 'lib/link_history.rb', line 92

def context_code_map(&block)
  @context_code.map(&block).tap do |ret|
    pp ['LinkState.context_code_map() ->', ret] if $pd
  end
end

#context_code_present?Boolean

Returns:

  • (Boolean)


98
99
100
101
102
# File 'lib/link_history.rb', line 98

def context_code_present?
  @context_code.present?.tap do |ret|
    pp ['LinkState.context_code_present?() ->', ret] if $pd
  end
end