Class: Spacy::Key
Instance Attribute Summary collapse
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#ctrl ⇒ Object
readonly
Returns the value of attribute ctrl.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#shift ⇒ Object
readonly
Returns the value of attribute shift.
Instance Method Summary collapse
- #<<(key) ⇒ Object
- #<=>(obj) ⇒ Object
- #eql?(obj) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(key, shift = false, ctrl = false, alt = false) ⇒ Key
constructor
A new instance of Key.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key, shift = false, ctrl = false, alt = false) ⇒ Key
Returns a new instance of Key.
13 14 15 |
# File 'lib/spacy/key.rb', line 13 def initialize (key, shift = false, ctrl = false, alt = false) @key, @shift, @ctrl, @alt = key.to_sym, shift, ctrl, alt end |
Instance Attribute Details
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
11 12 13 |
# File 'lib/spacy/key.rb', line 11 def alt @alt end |
#ctrl ⇒ Object (readonly)
Returns the value of attribute ctrl.
11 12 13 |
# File 'lib/spacy/key.rb', line 11 def ctrl @ctrl end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/spacy/key.rb', line 11 def key @key end |
#shift ⇒ Object (readonly)
Returns the value of attribute shift.
11 12 13 |
# File 'lib/spacy/key.rb', line 11 def shift @shift end |
Instance Method Details
#<<(key) ⇒ Object
25 26 27 28 |
# File 'lib/spacy/key.rb', line 25 def << (key) raise ArgumentError unless key.kind_of? Key KeyStroke.new << self << key end |
#<=>(obj) ⇒ Object
38 39 40 |
# File 'lib/spacy/key.rb', line 38 def <=> (obj) to_s <=> obj.to_s end |
#eql?(obj) ⇒ Boolean
34 35 36 |
# File 'lib/spacy/key.rb', line 34 def eql? (obj) to_s == obj.to_s end |
#hash ⇒ Object
30 31 32 |
# File 'lib/spacy/key.rb', line 30 def hash () to_s.hash end |
#inspect ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/spacy/key.rb', line 42 def inspect () mods = '' mods << ', shift' if @shift mods << ', ctrl' if @ctrl mods << ', alt' if @alt "#<Spacy::Key '#{@key.to_s}#{mods}'>" end |
#to_s ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/spacy/key.rb', line 17 def to_s () s = '' s << '/' if @alt s << '^' if @ctrl s << @key s end |