math_lesson 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +58 -0
- data/Rakefile +4 -0
- data/lib/math_lesson/version.rb +5 -0
- data/lib/math_lesson.rb +22 -0
- data/math_lesson.gemspec +39 -0
- data/sig/math_lesson.rbs +4 -0
- metadata +49 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 26168c10a088db66ef06b5ff4b95c1e648434c8bcfdf5e1a1c0488f2c4f71257
|
|
4
|
+
data.tar.gz: 1f021ac65d7471b5dc97dc3cde0ee382c864aea080b694a06258120706a8b605
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7600205da72fcea18352ddfbb070a34130e303e34d8e8a28ed1c39a02e4398cd4fea08d386dfe8a37de8802ec81997fd7cc91d3743ada261f1a4fc798b150078
|
|
7
|
+
data.tar.gz: 027be0bcb6de9e7b677fa074cfadf258ac79040ce5da68dac444748e544bcafb38e05609b1d11d08e23469201b2ba868f052696d7d646301745e688057bb9432
|
data/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# math_lesson
|
|
2
|
+
|
|
3
|
+
## 概要
|
|
4
|
+
|
|
5
|
+
はじめての gem
|
|
6
|
+
|
|
7
|
+
## gem の利用方法
|
|
8
|
+
|
|
9
|
+
1. Gemfile に `gem "math_lesson", require: "math_lesson"` を追記する
|
|
10
|
+
2. rails console を実行する
|
|
11
|
+
3. `require "math_lesson"` を入力する
|
|
12
|
+
4. `MathLesson.mutiple_scalar([1, 2], 3)` を入力する
|
|
13
|
+
|
|
14
|
+
## コマンド
|
|
15
|
+
|
|
16
|
+
| コマンド | 用途 |
|
|
17
|
+
| ----------------------------- | ---------------------------- |
|
|
18
|
+
| `ruby test/math_lesson.test.rb` | テスト実行 |
|
|
19
|
+
| `gem build math_lesson.gemspec` | 配布用 `.gem` ファイルを作成 |
|
|
20
|
+
| `gem push gem-name-0.1.0.gem` | RubyGems に gem を公開 |
|
|
21
|
+
|
|
22
|
+
## リンク
|
|
23
|
+
|
|
24
|
+
- https://rubygems.org/?locale=ja
|
|
25
|
+
- https://github.com/tsuji-108/ruby_gem_lesson
|
|
26
|
+
- https://zenn.dev/d0ne1s/articles/ded05b96bfbe0d
|
|
27
|
+
|
|
28
|
+
<!-- # MathLesson
|
|
29
|
+
|
|
30
|
+
TODO: Delete this and the text below, and describe your gem
|
|
31
|
+
|
|
32
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/math_lesson`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
|
37
|
+
|
|
38
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
39
|
+
|
|
40
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
|
41
|
+
|
|
42
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
43
|
+
|
|
44
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
TODO: Write usage instructions here
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
53
|
+
|
|
54
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/math_lesson. -->
|
data/Rakefile
ADDED
data/lib/math_lesson.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'matrix'
|
|
4
|
+
require_relative "math_lesson/version"
|
|
5
|
+
|
|
6
|
+
module MathLesson
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
|
|
9
|
+
# 縦ベクトルのスカラー倍
|
|
10
|
+
def self.mutiple_scalar(vec, scalar)
|
|
11
|
+
(Vector[*vec] * scalar).to_a
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# 縦ベクトル x 行列
|
|
15
|
+
# vec: [x, y, z] の縦ベクトル
|
|
16
|
+
# mat: 1 次配列を vec の要素数ごとに区切った行列。例: [x, 0, 0, 0, y, 0, 0, 0, 1] -> [[x, 0, 0], [0, y, 0], [0, 0, 1]]
|
|
17
|
+
def self.mutiple_matrix(vec, mat)
|
|
18
|
+
matrix = Matrix.rows(mat.each_slice(vec.size).to_a)
|
|
19
|
+
(matrix * Vector[*vec]).to_a
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
data/math_lesson.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/math_lesson/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "math_lesson"
|
|
7
|
+
spec.version = MathLesson::VERSION
|
|
8
|
+
spec.authors = ["tsuji-108"]
|
|
9
|
+
spec.email = ["atsuhiro-tsuji@gaji.jp"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "my first gem."
|
|
12
|
+
spec.description = "lesson of ruby and gem."
|
|
13
|
+
spec.homepage = "https://github.com/tsuji-108/ruby_gem_lesson"
|
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
15
|
+
|
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
17
|
+
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
(File.expand_path(f) == __FILE__) ||
|
|
27
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
# Uncomment to register a new dependency of your gem
|
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
36
|
+
|
|
37
|
+
# For more information and examples about making a new gem, check out our
|
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
39
|
+
end
|
data/sig/math_lesson.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: math_lesson
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- tsuji-108
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-02-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: lesson of ruby and gem.
|
|
14
|
+
email:
|
|
15
|
+
- atsuhiro-tsuji@gaji.jp
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- README.md
|
|
21
|
+
- Rakefile
|
|
22
|
+
- lib/math_lesson.rb
|
|
23
|
+
- lib/math_lesson/version.rb
|
|
24
|
+
- math_lesson.gemspec
|
|
25
|
+
- sig/math_lesson.rbs
|
|
26
|
+
homepage: https://github.com/tsuji-108/ruby_gem_lesson
|
|
27
|
+
licenses: []
|
|
28
|
+
metadata:
|
|
29
|
+
homepage_uri: https://github.com/tsuji-108/ruby_gem_lesson
|
|
30
|
+
post_install_message:
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: 2.6.0
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 3.5.3
|
|
46
|
+
signing_key:
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: my first gem.
|
|
49
|
+
test_files: []
|