Class: JSON::Editor::OptionsMenu

Inherits:
Object
  • Object
show all
Includes:
MenuExtension
Defined in:
lib/json/editor.rb

Instance Attribute Summary collapse

Attributes included from MenuExtension

#menu, #treeview

Instance Method Summary collapse

Methods included from MenuExtension

#add_item, #add_separator, #initialize, #method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JSON::Editor::MenuExtension

Instance Attribute Details

#pretty_itemObject (readonly)

Returns the value of attribute pretty_item.



678
679
680
# File 'lib/json/editor.rb', line 678

def pretty_item
  @pretty_item
end

Instance Method Details

#collapsed_nodes(item) ⇒ Object

Collapse/Expand all nodes by default.



662
663
664
665
666
667
668
669
670
# File 'lib/json/editor.rb', line 662

def collapsed_nodes(item)
  if expanded
    self.expanded = false
    collapse_all
  else
    self.expanded = true
    expand_all 
  end
end

#createObject

Create the menu.



681
682
683
684
685
686
687
688
689
690
# File 'lib/json/editor.rb', line 681

def create
  title = MenuItem.new('Options')
  title.submenu = menu
  add_item('Collapsed nodes', nil, CheckMenuItem, &method(:collapsed_nodes))
  @pretty_item = add_item('Pretty saving', nil, CheckMenuItem,
    &method(:pretty_saving))
  @pretty_item.active = true
  window.unchange
  title
end

#pretty_saving(item) ⇒ Object

Toggle pretty saving mode on/off.



673
674
675
676
# File 'lib/json/editor.rb', line 673

def pretty_saving(item)
  @pretty_item.toggled
  window.change
end