Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Active Support

Kento Nagata
October 16, 2015

Active Support

Kento Nagata

October 16, 2015
Tweet

More Decks by Kento Nagata

Other Decks in Programming

Transcript

  1. Active Supportͱ͸ʁ • Active Support͸Ruby on RailsͷίϯϙʔωϯτͰ ͋ΓɺRubyݴޠͷ֦ுɺϢʔςΟϦςΟɺͦͷଞԣ அతͳ࡞ۀΛ୲͍ͬͯ·͢ɻ •

    Active Support͸ݴޠϨϕϧͰجຊ෦෼Λఈ্͛͠ ͯ๛͔ͳ΋ͷʹ͠ɺRailsΞϓϦέʔγϣϯͷ։ൃͱ Ruby on RailsͦΕࣗମͷ։ൃʹ໾ཱͯΔ΂͘࡞ΒΕ ͍ͯ·͢ɻ Ҿ༻: http://railsguides.jp/active_support_core_extensions.html
  2. CoreExt Hash Class Date DateTime File Float Integer Kernel Module

    Enumerable Array String Autoload JSON Cache Notifications ActiveSupport:: Configurable Concern TimeZone XmlMini KeyGenerator Logger OrderedHash OrderedOptions Rescuable SecurityUtils TimeWithZone MessageVerifier MessageEncryptor Callbacks ArrayInquirer StringInquirer
  3. Object sizes = [1, 2, 3, 4, 5] sizes.try {

    |s| s.sum / s.size } # => 3 sizes = nil sizes.try { |s| s.sum / s.size } # => nil
  4. Object content = ‘The Jedi are a fictional and ancient

    monastic, spiritual, and academic meritocratic organization and the main protagonists in the fictional Star Wars universe, whose origins dates back to circa 25,000 BBY (Before Battle of Yavin; the destruction of the first Death Star).’ content.try { upcase.truncate } # => “THE JED...”
  5. String ‘Module’. constantize # => Module # ref 'puni_puni'.dasherize #

    => “puni-puni" ‘task_id’.humanize # => “Task” ‘test’.inquiry.test? # => true # StringInquirer
  6. Array %w(1 2 3 4 5 6 7 8 9

    10).in_groups(3) # => [ ["1", "2", "3", "4"] ["5", "6", "7", nil] ["8", "9", "10", nil] ]
  7. Array %w(1 2 3 4 5 6 7 8 9

    10).in_groups_of(3) # => [ ["1", "2", "3"] ["4", "5", "6"] ["7", "8", "9"] ["10", nil, nil] ]
  8. Array %w(1 2 3 4 5 6 7 8 9

    10).in_groups_of(3) # => [ ["1", "2", "3"] ["4", "5", "6"] ["7", "8", "9"] ["10", nil, nil] ]
  9. Array %w( a b c d e ).second # =>

    “b” %w( a b c d e ).third # => “c” %w( a b c d e ).fourth # => “d” %w( a b c d e ).fifth # => “e” (1..42).to_a.forty_two # => 42
  10. Hash options.reverse_merge({size: 25 , velocity: 3}) # `{size: 25 ,

    velocity: 3}.merge(options)`ͱಉ͡ # ண໨͍ͯ͠Δม਺ΛϨγʔόʹͰ͖Δ