Class: ATSPI::StateSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/atspi/state_set.rb

Overview

ATSPI::StateSet wraps libatspi’s AtspiStateSet

Lifecycle collapse

Modification collapse

Queries collapse

Representations collapse

Constructor Details

#initialize(*states) ⇒ StateSet

Parameters:

  • states (Symbols)

    zero, one or more symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making it lowercase.

See Also:



21
22
23
# File 'lib/atspi/state_set.rb', line 21

def initialize(*states)
  @native = Libatspi::StateSet.new(states)
end

Instance Method Details

#add(*states) ⇒ self

Adds states to the set

Examples:

s = ATSPI::StateSet.new   # => #<ATSPI::StateSet:0x15ae28014 @states=[]>
s.add(:active, :enabled)  # => #<ATSPI::StateSet:0x15ae28014 @states=[:active, :enabled]>

Parameters:

  • states (Symbols)

    zero, one or more symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making it lowercase.

Returns:

  • (self)

See Also:



43
44
45
46
# File 'lib/atspi/state_set.rb', line 43

def add(*states)
  states.each{ |state| @native.add(state) }
  self
end

#contains?(state) ⇒ true, false

Checks if it contains the given state

Examples:

ATSPI::StateSet.new(:active, :editable).contains?(:active) # => true

Parameters:

  • state (Symbol)

    the state as symbol derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making it lowercase.

Returns:

  • (true, false)

See Also:



80
81
82
# File 'lib/atspi/state_set.rb', line 80

def contains?(state)
  @native.contains(state)
end

#difference_to(state_set) ⇒ StateSet Also known as: ^

Returns the difference between it and another set

Examples:

s1 = ATSPI::StateSet.new(:active, :editable)  # => #<ATSPI::StateSet:0x15ae28014 @states=[:active, :editable]>
s2 = ATSPI::StateSet.new(:active, :enabled)   # => #<ATSPI::StateSet:0x119ea8c14 @states=[:active, :enabled]>
s1.difference_to(s2)                          # => #<ATSPI::StateSet:0x110b2b414 @states=[:editable, :enabled]>

Returns:

  • (StateSet)

    the difference to the given set

See Also:



106
107
108
# File 'lib/atspi/state_set.rb', line 106

def difference_to(state_set)
  StateSet.new_from_native @native.compare(state_set.__send__(:native))
end

#empty?true, false

Checks if it is empty

Examples:

ATSPI::StateSet.new(:active, :editable).empty? # => false

Returns:

  • (true, false)

See Also:



92
93
94
# File 'lib/atspi/state_set.rb', line 92

def empty?
  @native.is_empty
end

#equals?(state_set) ⇒ true, false Also known as: ==

Checks if it equals another set

Examples:

s1 = ATSPI::StateSet.new(:active, :editable)  # => #<ATSPI::StateSet:0x15ae28014 @states=[:active, :editable]>
s2 = ATSPI::StateSet.new(:active, :enabled)   # => #<ATSPI::StateSet:0x119ea8c14 @states=[:active, :enabled]>
s1.equals?(s2)                                # => false

Returns:

  • (true, false)

See Also:



121
122
123
# File 'lib/atspi/state_set.rb', line 121

def equals?(state_set)
  @native.equals state_set.__send__(:native)
end

#inspectString

Returns itself as an inspectable string.

Returns:

  • (String)

    itself as an inspectable string



136
137
138
# File 'lib/atspi/state_set.rb', line 136

def inspect
  "#<#{self.class.name}:0x#{'%x14' % __id__} @states=#{to_a.inspect}>"
end

#remove(*states) ⇒ self

Removes states from the set

Examples:

s = ATSPI::StateSet.new(:active, :enabled)  # => #<ATSPI::StateSet:0x15ae28014 @states=[:active, :enabled]>
s.remove(:active)                           # => #<ATSPI::StateSet:0x15ae28014 @states=[:enabled]>

Parameters:

  • states (Symbols)

    zero, one or more symbols derived from libatspi’s AtspiStateType enum by removing the prefix ATSPI_STATE_ and making it lowercase.

Returns:

  • (self)

See Also:



61
62
63
64
# File 'lib/atspi/state_set.rb', line 61

def remove(*states)
  states.each{ |state| @native.remove(state) }
  self
end

#to_aArray<Symbol>

Returns the states it contains.

Returns:

  • (Array<Symbol>)

    the states it contains

See Also:



131
132
133
# File 'lib/atspi/state_set.rb', line 131

def to_a
  @native.states.to_a
end