This file contains hidden or 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
| $('#js-multiple-timesheet-employee-daily-records-table tr').each((i, e)=>{ | |
| if (!/平日/.test(e.textContent)) return; | |
| $('.add_fields',e).click(); | |
| $('[name*="elapsed_minutes_at_work_in_with_neuminour_string_format"]', e)[0].value = '10:00'; | |
| $('[name*="elapsed_minutes_at_work_out_with_neuminour_string_format"]', e)[0].value = '19:00'; | |
| }) |
This file contains hidden or 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
| # RGB変換プログラム | |
| # 3つの10進数を受け取り、それぞれを16進数に変換した文字列を返す | |
| def to_hex(*args) | |
| arry = args.map {|s|s.to_s(16).rjust(2,"0")} | |
| p "##{arry.join}" | |
| end | |
| to_hex(255, 255, 255) | |
| to_hex(4, 60, 120) |
This file contains hidden or 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 convert_length(num, unit, conversion) | |
| hash = {'m' => 1.00, 'ft' => 3.28, 'in' => 39.37} | |
| (num * hash[conversion] / hash[unit]).round(2) | |
| end | |
| puts convert_length(1, 'm', 'in') | |
| puts convert_length(15, 'in', 'm') | |
| puts convert_length(35_000, 'ft', 'm') |
This file contains hidden or 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
| # 正規表現変換 | |
| old_syntax = <<TEXT | |
| { | |
| :name => 'Alice', | |
| :age=>20, | |
| :gender => :female | |
| } | |
| TEXT |
This file contains hidden or 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
| # 改札機プログラム(自力作) | |
| STATION = ['harajyuku', 'omotesando', 'nogizaka'] | |
| class Gate | |
| attr_accessor :name | |
| def initialize(name) | |
| @name = name | |
| end |
This file contains hidden or 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を使う DeepFreeze(自作) | |
| module Freeze | |
| def deep_freeze(object) | |
| object.freeze | |
| object.each do |element, value| | |
| element.freeze | |
| value&.freeze | |
| end | |
| end | |
| end |
This file contains hidden or 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
| # 例外処理 サンプルそのまま | |
| print "Text?:" | |
| text = gets.chomp | |
| begin | |
| print "Pattern?:" | |
| pattern = gets.chomp | |
| regexp = Regexp.new(pattern) | |
| rescue RegexpError => e | |
| puts "Invalid regexp #{e.message}" | |
| retry |
This file contains hidden or 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
| # count 再実装 | |
| class Array | |
| def count(*args) | |
| if block_given? | |
| num = 0 | |
| each { |i| num += 1 if yield(i) } | |
| num | |
| elsif args.empty? | |
| size | |
| else |
This file contains hidden or 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
| # frozen_string_literal: true | |
| # block | |
| # simple | |
| def say_fact | |
| if block_given? | |
| puts 'i got block' | |
| else | |
| puts 'i need block' |
This file contains hidden or 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
| # Ruby Document | |
| # https://docs.ruby-lang.org/ja/latest/class/Enumerable.html#I_PARTITION | |
| # github: holiday_japan | |
| # https://github.com/masa16/holiday_japan/blob/master/lib/holiday_japan.rb | |
| require 'holiday_japan' | |
| # Enumerable#partitionを使い2020年の祝日がある月を抽出する |
OlderNewer