lib/gnuplotrb/mixins/option_handling.rb
##
# Create new Plot (or Dataset or Splot or Multiplot) object where current
# options are merged with given. If no options
# given it will just return existing set of options.
#
# @param options [Hash] options to add
# @return [Dataset, Splot, Multiplot] new object created with given options
# @return [Hamster::Hash] current options if given options empty
# @example
#   sin_graph = Plot.new(['sin(x)', title: 'Sin'], title: 'Sin on [0:3]', xrange: 0..3)
#   sin_graph.plot
#   sin_graph_update = sin_graph.options(title: 'Sin on [-10:10]', xrange: -10..10)
#   sin_graph_update.plot
#   # sin_graph IS NOT affected
Create new Plot (or Dataset or Splot or Multiplot) object where current
options are merged with given. If no options
given it will just return existing set of options.
Create new Plot ( or Dataset or Splot or Multiplot ) object where current options are merged with given . If no options given it will just return existing set of options .
def options(**options)
      @options ||= Hamster::Hash.new
      if options.empty?
        @options
      else
        new_with_options(@options.merge(options))
      end
    end
def options ( ** options ) @options ||= Hamster :: Hash . new if options . empty? @options else new_with_options ( @options . merge ( options ) ) end end
Create new Plot (or Dataset or Splot or Multiplot) object where current
options are merged with given.
Create new Plot ( or Dataset or Splot or Multiplot ) object where current options are merged with given .
new object created with given options
new object created with given options
Dataset, Splot, Multiplot
current options if given options empty
current options if given options empty
Hamster::Hash
options
options to add
options to add
example
sin_graph = Plot.new(['sin(x)', title: 'Sin'], title: 'Sin on [0:3]', xrange: 0..3) sin_graph.plot sin_graph_update = sin_graph.options(title: 'Sin on [-10:10]', xrange: -10..10) sin_graph_update.plot # sin_graph IS NOT affected
sin_graph = Plot . new ( [ ' sin ( x ) ' title : ' Sin ' ] title : ' Sin on [ 0 : 3 ] ' xrange : 0 .. 3 ) sin_graph . plot sin_graph_update = sin_graph . options ( title : ' Sin on [ - 10 : 10 ] ' xrange : - 10 .. 10 ) sin_graph_update . plot # sin_graph IS NOT affected