Class: LcpRuby::Dsl::SectionBuilder

Inherits:
Object
  • Object
show all
Includes:
SourceLocationCapture
Defined in:
lib/lcp_ruby/dsl/presenter_builder.rb

Instance Method Summary collapse

Methods included from SourceLocationCapture

capture_source_loc

Constructor Details

#initializeSectionBuilder

Returns a new instance of SectionBuilder.



734
735
736
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 734

def initialize
  @fields = []
end

Instance Method Details

#divider(label: nil) ⇒ Object



747
748
749
750
751
752
753
754
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 747

def divider(label: nil)
  d = { "type" => "divider" }
  if label
    d["label"] = label
    d["_label_source_loc"] = capture_source_loc
  end
  @fields << d
end

#field(name, **options) ⇒ Object



738
739
740
741
742
743
744
745
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 738

def field(name, **options)
  field_hash = { "field" => name.to_s }
  options.each do |k, v|
    field_hash[k.to_s] = v.is_a?(Symbol) ? v.to_s : HashUtils.stringify_deep(v)
  end
  field_hash["_label_source_loc"] = capture_source_loc if options.key?(:label)
  @fields << field_hash
end

#info(text) ⇒ Object



756
757
758
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 756

def info(text)
  @fields << { "type" => "info", "text" => text }
end

#to_fieldsObject



760
761
762
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 760

def to_fields
  @fields
end