lib/hierarchy_string.rb in markdown_exec-2.5.0 vs lib/hierarchy_string.rb in markdown_exec-2.6.0
- old
+ new
@@ -28,11 +28,11 @@
# to be manipulated or transformed in a consistent and customizable manner.
class HierarchyString
attr_accessor :substrings
# Initialize with a single hash or an array of hashes
- def initialize(substrings, text_sym: :text, style_sym: :color)
+ def initialize(substrings = [], text_sym: :text, style_sym: :color)
@substrings = parse_substrings(substrings)
@text_sym = text_sym
@style_sym = style_sym
end
@@ -78,9 +78,13 @@
end
# Method to decorate all substrings into a single string
def decorate
decorate_substrings(@substrings)
+ end
+
+ def padded_width
+ concatenate.length
end
# Handle string inspection methods and pass them to the concatenated string
def method_missing(method_name, *arguments, &block)
if ''.respond_to?(method_name)