lib/link_history.rb in markdown_exec-2.3.0 vs lib/link_history.rb in markdown_exec-2.4.0
- old
+ new
@@ -7,27 +7,28 @@
module MarkdownExec
class LinkState
attr_accessor :block_name, :display_menu, :document_filename,
:inherited_block_names, :inherited_dependencies,
- :prior_block_was_link
+ :keep_code, :prior_block_was_link
# Initialize the LinkState with keyword arguments for each attribute.
# @param block_name [String, nil] the name of the block.
# @param document_filename [String, nil] the filename of the document.
# @param inherited_block_names [Array<String>, nil] the names of the inherited blocks.
# @param inherited_dependencies [?, nil] the dependecy hierarcy.
# @param inherited_lines [Array<String>, nil] the inherited lines of code.
def initialize(block_name: nil, display_menu: nil, document_filename: nil,
inherited_block_names: [], inherited_dependencies: nil, inherited_lines: nil,
- prior_block_was_link: 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
# Creates an empty LinkState instance.
# @return [LinkState] an instance with all attributes set to their default values.
@@ -44,40 +45,53 @@
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
def inherited_lines
- @inherited_lines.tap { |ret| pp ['LinkState.inherited_lines() ->', ret] if $pd }
+ @inherited_lines.tap { |ret|
+ pp ['LinkState.inherited_lines() ->', ret] if $pd
+ }
end
def inherited_lines=(value)
- @inherited_lines = value.tap { |ret| pp ['LinkState.inherited_lines=() ->', ret] if $pd }
+ @inherited_lines = value.tap { |ret|
+ pp ['LinkState.inherited_lines=() ->', ret] if $pd
+ }
end
def inherited_lines_append(value)
- @inherited_lines = ((@inherited_lines || []) + value).tap { |ret| pp ['LinkState.inherited_lines_append() ->', ret] if $pd }
+ @inherited_lines = ((@inherited_lines || []) + value).tap { |ret|
+ pp ['LinkState.inherited_lines_append() ->', ret] if $pd
+ }
end
def inherited_lines_block
- @inherited_lines.join("\n").tap { |ret| pp ['LinkState.inherited_lines_block() ->', ret] if $pd }
+ (@inherited_lines || []).join("\n").tap { |ret|
+ pp ['LinkState.inherited_lines_block() ->', ret] if $pd
+ }
end
def inherited_lines_count
- (@inherited_lines&.count || 0).tap { |ret| pp ['LinkState.inherited_lines_count() ->', ret] if $pd }
+ (@inherited_lines&.count || 0).tap { |ret|
+ pp ['LinkState.inherited_lines_count() ->', ret] if $pd
+ }
end
def inherited_lines_map
@inherited_lines.map do |line|
yield line
end.tap { |ret| pp ['LinkState.inherited_lines_map() ->', ret] if $pd }
end
def inherited_lines_present?
- @inherited_lines.present?.tap { |ret| pp ['LinkState.inherited_lines_present?() ->', ret] if $pd }
+ @inherited_lines.present?.tap { |ret|
+ pp ['LinkState.inherited_lines_present?() ->', ret] if $pd
+ }
end
end
class LinkHistory
def initialize