Lightning talk 2

12
Shitceptions Wednesday, June 19, 13

description

 

Transcript of Lightning talk 2

Page 1: Lightning talk 2

Shitceptions

Wednesday, June 19, 13

Page 2: Lightning talk 2

github.com/theverything theverythingy

Active Support

Wednesday, June 19, 13

Page 3: Lightning talk 2

require 'active_support/all'require 'active_support/core_ext'require 'active_support/core_ext/hash'require 'active_support/core_ext/hash/slice'

Active Support all up in your Rails

To add it to any project

gem 'activesupport'

Wednesday, June 19, 13

Page 4: Lightning talk 2

Active Support adds extensions to...

Wednesday, June 19, 13

Page 5: Lightning talk 2

Active Support adds extensions to...Array, BigDecimal, Class, Date, DateTime, File, Float, Hash, Integer, Kernel, Module, Numeric, Object, Process, Range, String, and Time

Wednesday, June 19, 13

Page 6: Lightning talk 2

String "hello world".truncate(9)=> "hello ..."

'person'.pluralize=> "people"

'people'.singularize=> "person"

"hello world".titleize=> "Hello World"

"Hello World!!".parameterize=> "hello-world"

"hello_world".camelize=> "HelloWorld"

"HelloWorld".underscore=> "hello_world"

Wednesday, June 19, 13

Page 7: Lightning talk 2

Integer &Enumerable

1.ordinalize=> "1st"

2.ordinalize=> "2nd"

3.ordinalize=> "3rd"

4.ordinalize=> "4th"

[1, 2, 3, 4, 5].sum=> 15

Wednesday, June 19, 13

Page 8: Lightning talk 2

[1, 2, 3, 4, 5].second=> 2

[1, 2, 3, 4, 5].third=> 3

[1, 2, 3, 4, 5].fourth=> 4

[1, 2, 3, 4, 5].fifth=> 5

(1..100).to_a.forty_two=> 42

["one", "two", "three"].to_sentence=> "one, two, and three"

[1, 2, 3, 4, 5, 6, 7].in_groups_of(2)=> [[1, 2], [3, 4], [5, 6], [7, nil]]

Array

Wednesday, June 19, 13

Page 9: Lightning talk 2

[1, 2, 3, 4, 5].second=> 2

[1, 2, 3, 4, 5].third=> 3

[1, 2, 3, 4, 5].fourth=> 4

[1, 2, 3, 4, 5].fifth=> 5

(1..100).to_a.forty_two=> 42

["one", "two", "three"].to_sentence=> "one, two, and three"

[1, 2, 3, 4, 5, 6, 7].in_groups_of(2)=> [[1, 2], [3, 4], [5, 6], [7, nil]]

Array

Wednesday, June 19, 13

Page 10: Lightning talk 2

Hash{ one: "hello", two: "world", three: "yay" }.to_query=> "one=hello&three=yay&two=world"

{ one: "hello", two: "world", three: "yay" }.slice(:one, :three)=> {:one=>"hello", :three=>"yay"}

{ one: "hello", two: "world", three: "yay" }.except(:one)=> {:two=>"world", :three=>"yay"}

Wednesday, June 19, 13

Page 11: Lightning talk 2

to_param

["one", "two", "three"].to_param=> "one/two/three"

class Post < ActiveRecord::Base def to_param "#{created_at.strftime("%m-%d-%y")}-

#{title.parameterize}" endend

post_path(@post) # => "6-19-13-hello-world"

Wednesday, June 19, 13

Page 12: Lightning talk 2

Questions?

github.com/theverything theverythingy

Wednesday, June 19, 13