Module: Daru::View

Defined in:
lib/daru/view.rb,
lib/daru/view/plot.rb,
lib/daru/view/table.rb,
lib/daru/view/version.rb,
lib/daru/view/plot_list.rb,
lib/daru/view/adapters/nyaplot.rb,
lib/daru/view/app/rails/railtie.rb,
lib/daru/view/adapters/datatables.rb,
lib/daru/view/adapters/highcharts.rb,
lib/daru/view/adapters/googlecharts.rb,
lib/daru/view/app/rails/helpers/view_helper.rb

Defined Under Namespace

Modules: Adapter, Rails Classes: Engine, Plot, PlotList, Table

Constant Summary collapse

VERSION =
'0.2.6'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.plotting_libraryObject

Returns the value of attribute plotting_library.



27
28
29
# File 'lib/daru/view.rb', line 27

def plotting_library
  @plotting_library
end

.table_libraryObject

Returns the value of attribute table_library.



27
28
29
# File 'lib/daru/view.rb', line 27

def table_library
  @table_library
end

Class Method Details

.dependent_script(lib = :nyaplot) ⇒ void, String

dependent script for the library. It must be added in the head tag of the web application.

Examples:

dep_js = Daru::View.dependent_script(:highcharts)
use in Rails app : <%=raw dep_js %>
dep_js = Daru::View.dependent_script('highcharts')
use in Rails app : <%=raw dep_js %>
To load the dependent JS file for Nyaplot library
plotting system (Nyaplot.js, d3.js):

Daru::View.dependent_script(:nyaplot)
Daru::View.dependent_script('nyaplot')

Parameters:

  • lib (String, Symbol) (defaults to: :nyaplot)

    library whose dependencies are to be loaded

Returns:

  • (void, String)

    dependent script for the library



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/daru/view.rb', line 94

def dependent_script(lib=:nyaplot)
  load_lib_in_iruby(lib.to_s) if defined? IRuby
rescue NameError
  case lib.to_s
  when 'nyaplot'
    Nyaplot.init_script
  when 'highcharts'
    LazyHighCharts.init_script
  when 'googlecharts'
    GoogleVisualr.init_script
  when 'datatables'
    DataTables.init_script
  else
    raise ArgumentError, "Unsupported library #{lib}"
  end
end

.dependent_scripts(libraries = []) ⇒ void, String

Returns dependent script for the libraries.

Examples:

To load the dependent JS file for Nyaplot and GoogleCharts libraries
Daru::View.dependent_scripts(['nyaplot', 'googlecharts'])
To load the dependent JS file for Nyaplot and GoogleCharts libraries
Daru::View.dependent_scripts([:nyaplot, :googlecharts])

Parameters:

  • libraries (Array) (defaults to: [])

    libraries whose dependencies are to be loaded

Returns:

  • (void, String)

    dependent script for the libraries



121
122
123
124
125
126
127
128
129
# File 'lib/daru/view.rb', line 121

def dependent_scripts(libraries=[])
  load_libs_in_iruby(libraries) if defined? IRuby
rescue NameError
  script = ''
  libraries.each do |library|
    script << dependent_script(library)
  end
  script
end