Class: LcpRuby::Dsl::SectionBuilder
- Inherits:
-
Object
- Object
- LcpRuby::Dsl::SectionBuilder
- Includes:
- SourceLocationCapture
- Defined in:
- lib/lcp_ruby/dsl/presenter_builder.rb
Instance Method Summary collapse
- #divider(label: nil) ⇒ Object
- #field(name, **options) ⇒ Object
- #info(text) ⇒ Object
-
#initialize ⇒ SectionBuilder
constructor
A new instance of SectionBuilder.
- #to_fields ⇒ Object
Methods included from SourceLocationCapture
Constructor Details
#initialize ⇒ SectionBuilder
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, **) field_hash = { "field" => name.to_s } .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 .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_fields ⇒ Object
760 761 762 |
# File 'lib/lcp_ruby/dsl/presenter_builder.rb', line 760 def to_fields @fields end |