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
it 'has a method that will call the transaction class' do | |
Transaction.should_receive(:new); | |
bank.send(:make_deposit, 5); | |
end | |
def make_deposit(amount) | |
Transaction.new(self, 'deposit', amount); | |
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
<table> | |
<tr> | |
<th>Subject</th> | |
<th>Created At</th> | |
<th>Status</th> | |
</tr> | |
<% @tickets.each do |ticket| %> | |
<tr> | |
<td><a href="/ticket/<%= ticket.id %>"><%= ticket.subject %></a></td> |
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
totalprice=0 | |
totalitemcount=0 | |
laborcharge=0 | |
discount= 0 | |
totalgccount=0 |
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 'concurrent' | |
class Test | |
def update(time, value, reason) | |
puts "OMG" | |
end | |
end | |
puts 'testing . . .' |
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 ApiRead | |
require 'open-uri' | |
require 'json' | |
attr_reader :data | |
def initialize(url) | |
# this goes fine | |
@data = JSON.parse(open(url).read)["data"] | |
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
defmodule Scrabble do | |
def score(l) when l in [nil, ""] do: 0 | |
def score(l) when l in ["A", "E", "I", "O", "U"] do: 1 | |
def score(word) do | |
word | |
|> String.upcase | |
|> String.split("") | |
|> Enum.map(&(score(&1))) | |
|> Enum.sum |
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 if_statement | |
return a unless condition? | |
c( | |
1, | |
2, | |
3 | |
) | |
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
def if_statement | |
a | |
if condition? | |
c( | |
1, | |
2, | |
3 | |
) | |
end | |
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
class Parent < ActiveRecord::Base | |
has_many :children | |
#Question: Does method below perform a join in children and match only children belonging to a specific parent? | |
def has_active_children | |
children.exists?(status: "active") | |
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
# Fetchs campaigns from SiB | |
class CampaignFetch | |
def get | |
def sib | |
@sib ||= Mailin.new("API_URL","API_KEY") | |
end | |
def shoot_criteria | |
{ "type"=>"classic", "status" => "sent", "page"=>10,"page_limit"=>1000 } |
NewerOlder