Class: Fatty::MouseGesture

Inherits:
Object
  • Object
show all
Defined in:
lib/fatty/key_map.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(button:, ctrl:, meta:, shift:) ⇒ MouseGesture

Returns a new instance of MouseGesture.



67
68
69
70
71
72
# File 'lib/fatty/key_map.rb', line 67

def initialize(button:, ctrl:, meta:, shift:)
  @button = button
  @ctrl = ctrl
  @meta = meta
  @shift = shift
end

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



65
66
67
# File 'lib/fatty/key_map.rb', line 65

def button
  @button
end

#ctrlObject (readonly)

Returns the value of attribute ctrl.



65
66
67
# File 'lib/fatty/key_map.rb', line 65

def ctrl
  @ctrl
end

#metaObject (readonly)

Returns the value of attribute meta.



65
66
67
# File 'lib/fatty/key_map.rb', line 65

def meta
  @meta
end

#shiftObject (readonly)

Returns the value of attribute shift.



65
66
67
# File 'lib/fatty/key_map.rb', line 65

def shift
  @shift
end

Class Method Details

.from_event(event) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/fatty/key_map.rb', line 74

def self.from_event(event)
  new(
    button: event.button,
    ctrl: !!event.ctrl,
    meta: !!event.meta,
    shift: !!event.shift,
  )
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



83
84
85
86
87
88
89
# File 'lib/fatty/key_map.rb', line 83

def ==(other)
  other.is_a?(self.class) &&
    button == other.button &&
    ctrl == other.ctrl &&
    meta == other.meta &&
    shift == other.shift
end

#hashObject



92
93
94
# File 'lib/fatty/key_map.rb', line 92

def hash
  [self.class, button, ctrl, meta, shift].hash
end

#inspectObject



96
97
98
# File 'lib/fatty/key_map.rb', line 96

def inspect
  "#<#{self.class} button=#{button.inspect} ctrl=#{ctrl} meta=#{meta} shift=#{shift}>"
end