Class: Glimmer::DSL::Libui::StringExpression

Inherits:
Expression
  • Object
show all
Includes:
ParentExpression
Defined in:
lib/glimmer/dsl/libui/string_expression.rb

Instance Method Summary collapse

Instance Method Details

#add_content(parent, keyword, *args, &block) ⇒ Object



48
49
50
51
52
# File 'lib/glimmer/dsl/libui/string_expression.rb', line 48

def add_content(parent, keyword, *args, &block)
  options = args.last.is_a?(Hash) ? args.last : {}
  options[:post_add_content] = true if !options.include?(:post_add_content)
  parent&.post_add_content(block) if options[:post_add_content]
end

#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/glimmer/dsl/libui/string_expression.rb', line 32

def can_interpret?(parent, keyword, *args, &block)
  keyword == 'string' and
    (
      parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy) or
      (parent.is_a?(Glimmer::LibUI::AttributedString) and !args.empty?)
    )
end

#interpret(parent, keyword, *args, &block) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/glimmer/dsl/libui/string_expression.rb', line 40

def interpret(parent, keyword, *args, &block)
  if parent.is_a?(Glimmer::LibUI::ControlProxy::TextProxy)
    Glimmer::LibUI::AttributedString.new(keyword, parent, args, &block)
  else
    parent.string = args.join
  end
end