This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_boolean(value, nil_value = false) | |
compare_value = value.class == String ? value.downcase : value | |
case compare_value | |
when "no","false",false, "0", 0 | |
false | |
when "yes","true",true, "1", 1 | |
true | |
when nil | |
nil_value | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts array_of_hashes.select{|i| array_of_hashes.select{|s|s[:key]==i[:key]}.count > 1}.map {|show| "#{show[:key]} #{show[:name]}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select sum(amount) total | |
, ds item_date | |
, LEFT(ds, 4) item_year | |
, SUBSTRING_INDEX(ds,'-',-1) item_day | |
, LEFT(SUBSTRING(ds,INSTR(ds,'-')+1), 2) item_month | |
, created_at | |
, td | |
from temp_ps | |
group by ds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x in 1..100 do | |
if (x % 3 == 0) && (x % 5 == 0) | |
puts "fizzbuzz" | |
elsif (x % 3 == 0) | |
puts "fizz" | |
elsif (x % 5 == 0) | |
puts "buzz" | |
else | |
puts x | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DataGrid | |
class Section | |
attr_reader :care_area, :patient_population, :total_records, :data_section | |
def initialize(care_area, population, total_records, drug_records) | |
@care_area = care_area | |
@patient_population = population | |
@total_records = total_records | |
@data_section = drug_records | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DataGrid | |
class Page | |
attr_reader :page_no, :sections | |
def initialize(page_no, type) | |
@page_no = page_no | |
@sections = [] | |
@type = type | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "prawn" | |
require "prawn/layout" | |
require "prawn/measurement_extensions" | |
module DataGrid | |
#colors | |
TEXT_COLOR = "000000" | |
DEFAULT_BG_COLOR = "ffffff" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SpreadsheetRowEnumerator | |
include Enumerable | |
def initialize(file_name, sheet_name, starting_row = 2) | |
parsing_class = case File.extname(file_name) | |
when ".xls": Excel | |
when ".xlsm", ".xlsx": ExcelxNokogiri | |
end | |
@starting_row = starting_row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataGridExporter | |
class << self | |
def export(data_grid) | |
returning(StringIO.new) do |buffer| | |
DataGridExporter.new(data_grid).build_workbook.write buffer | |
end.string | |
end | |
def quantity_unit_map | |
{"dosing_cumulative_max_quantity" => "dosing_cumulative_max_unit" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DrugRecordDataGridPresenter | |
extend Forwardable | |
attr_reader :data_grid, :view | |
def_delegators :data_grid, :each_row, :each_header_group, :configure_unit_field_formatters | |
def initialize(options = {}) | |
@data_grid = options[:grid] | |
@view = options[:view] |
NewerOlder