Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第01章 仮実装 #5

Merged
merged 18 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions part01/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions part01/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/doc/
/lib/
/bin/
/.shards/
!/.vscode/
1 change: 1 addition & 0 deletions part01/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: crystal
30 changes: 30 additions & 0 deletions part01/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Crystal spec all",
"type": "shell",
"command": "sh -c 'cd ${workspaceRoot} && crystal spec'",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
}
},
{
"taskName": "Crystal spec current",
"type": "shell",
"command": "sh -c 'cd ${workspaceRoot} && crystal spec ${relativeFile}:${lineNumber}'",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
21 changes: 21 additions & 0 deletions part01/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 at-grandpa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions part01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 第01章 仮実装
13 changes: 13 additions & 0 deletions part01/shard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: part01
version: 0.1.0

authors:
- at-grandpa <yoshiyuki.tsuchida.k@gmail.com>

targets:
part01:
main: src/money.cr

crystal: 0.23.1

license: MIT
11 changes: 11 additions & 0 deletions part01/spec/money_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "./spec_helper"

describe Money do
describe "multiplication" do
it "$5 * 2 = 10 になること" do
five = Money::Dollar.new(5)
five.times(2)
five.amount.should eq 10
end
end
end
2 changes: 2 additions & 0 deletions part01/spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "spec"
require "../src/money"
4 changes: 4 additions & 0 deletions part01/src/money.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require "./money/*"

module Money
end
12 changes: 12 additions & 0 deletions part01/src/money/dollar.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Money
class Dollar
property amount : Int32

def initialize(@amount : Int32)
end

def times(multiplier : Int32)
@amount *= multiplier
end
end
end