Class: Yast::Term

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable, Enumerable
Defined in:
src/ruby/yast/ops.rb,
src/ruby/yast/term.rb,
src/ruby/yast/yast.rb

Overview

predefine term to avoid circular dependency

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, *params) ⇒ Term

Returns a new instance of Term.



44
45
46
47
# File 'src/ruby/yast/term.rb', line 44

def initialize(value, *params)
  @value = value
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

term parameters



42
43
44
# File 'src/ruby/yast/term.rb', line 42

def params
  @params
end

#valueObject (readonly)

term symbol



40
41
42
# File 'src/ruby/yast/term.rb', line 40

def value
  @value
end

Instance Method Details

#<<Object

Append element to params

See Also:

  • Array#<<


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#<=>(other) ⇒ Object



90
91
92
93
94
95
96
97
# File 'src/ruby/yast/term.rb', line 90

def <=>(other)
  return nil unless other.is_a? self.class
  res = value <=> other.value
  return res if res != 0

  list = Ops.comparable_object(params)
  list <=> other.params
end

#[]Object

Access element of params

See Also:

  • Array#[]


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#[]=Object

Assign element to params

See Also:

  • Array#[]=


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#cloneObject



82
83
84
# File 'src/ruby/yast/term.rb', line 82

def clone
  Yast::Term.new value, *Yast.deep_copy(params)
end

#eachObject

Delegated directly to params

See Also:

  • Array#each


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#empty?true, false

Returns if params are empty.

Returns:

  • (true, false)

    if params are empty

See Also:

  • Array#empty?


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#nested_find(&block) ⇒ Object?

Find Object that match block even if it is in deep structure of nested terms last_hbox = content.nested_find do |t| t.all? { |i| i.value == :InputField } end last_hbox << InputField(Id(:input3), "Input3") if more_info?

Examples:

how to find widget in complex term

# UIShortcuts included
content = VBox(
            HBox(
              VBox(
                Hbox(
                  InputField(Id(:input1), "Input1"),
                  InputField(Id(:input2), "Input2")
                )
              )
            )
          )

Returns:

  • (Object, nil)

    returns nil if doesn't find matching element



69
70
71
72
73
74
75
76
77
78
79
80
# File 'src/ruby/yast/term.rb', line 69

def nested_find(&block)
  res = find(&block)
  return res if res

  each do |o|
    next unless o.respond_to?(:nested_find)
    res = o.nested_find(&block)
    break if res
  end

  res
end

#sizeInteger

Returns size of params.

Returns:

  • (Integer)

    size of params

See Also:

  • Array#size


37
# File 'src/ruby/yast/term.rb', line 37

def_delegators :@params, :each, :size, :empty?, :[], :[]=, :<<

#to_sObject



86
87
88
# File 'src/ruby/yast/term.rb', line 86

def to_s
  "`#{value} (#{params.map { |p| Yast::Builtins.inside_tostring p }.join ", "})"
end