Class: ShuttleCli::Bookmark
- Inherits:
-
Object
- Object
- ShuttleCli::Bookmark
- Defined in:
- lib/shuttle_cli/bookmark.rb
Constant Summary collapse
- @@bookmark_number =
1
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/shuttle_cli/bookmark.rb', line 3 def children @children end |
#cmd ⇒ Object
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/shuttle_cli/bookmark.rb', line 3 def cmd @cmd end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/shuttle_cli/bookmark.rb', line 3 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/shuttle_cli/bookmark.rb', line 3 def number @number end |
Class Method Details
.new_from_json(json) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/shuttle_cli/bookmark.rb', line 7 def self.new_from_json json obj = new # We are looking at a deep nested hash if we have more than 1 values. if json.length == 1 obj.name = json.keys.first obj.children = json.values.flatten.map do |h| # Recursive extract again new_from_json h end else obj.name = json[:name] obj.cmd = json[:cmd] end obj.number = @@bookmark_number @@bookmark_number += 1 obj end |
Instance Method Details
#connect ⇒ Object
29 30 31 |
# File 'lib/shuttle_cli/bookmark.rb', line 29 def connect system(cmd) end |
#to_a ⇒ Object
25 26 27 |
# File 'lib/shuttle_cli/bookmark.rb', line 25 def to_a [number, name, cmd] end |