aixm 1.2.1 → 1.3.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +23 -3
- data/README.md +37 -2
- data/exe/ckmid +1 -7
- data/exe/mkmid +1 -7
- data/lib/aixm/classes.rb +3 -1
- data/lib/aixm/component/address.rb +12 -15
- data/lib/aixm/component/approach_lighting.rb +11 -16
- data/lib/aixm/component/fato.rb +22 -34
- data/lib/aixm/component/frequency.rb +10 -15
- data/lib/aixm/component/geometry/arc.rb +2 -3
- data/lib/aixm/component/geometry/border.rb +6 -10
- data/lib/aixm/component/geometry/circle.rb +4 -4
- data/lib/aixm/component/geometry/point.rb +4 -4
- data/lib/aixm/component/geometry/rhumb_line.rb +4 -4
- data/lib/aixm/component/geometry.rb +4 -4
- data/lib/aixm/component/helipad.rb +13 -20
- data/lib/aixm/component/layer.rb +6 -8
- data/lib/aixm/component/lighting.rb +12 -17
- data/lib/aixm/component/runway.rb +26 -38
- data/lib/aixm/component/service.rb +12 -16
- data/lib/aixm/component/surface.rb +8 -10
- data/lib/aixm/component/timesheet.rb +9 -10
- data/lib/aixm/component/timetable.rb +6 -7
- data/lib/aixm/component/vasis.rb +6 -8
- data/lib/aixm/component/vertical_limit.rb +8 -8
- data/lib/aixm/component.rb +3 -2
- data/lib/aixm/concerns/association.rb +381 -0
- data/lib/aixm/concerns/memoize.rb +107 -0
- data/lib/aixm/concerns/xml_builder.rb +34 -0
- data/lib/aixm/document.rb +52 -21
- data/lib/aixm/feature/airport.rb +44 -47
- data/lib/aixm/feature/airspace.rb +29 -34
- data/lib/aixm/feature/generic.rb +67 -0
- data/lib/aixm/feature/navigational_aid/designated_point.rb +11 -13
- data/lib/aixm/feature/navigational_aid/dme.rb +12 -15
- data/lib/aixm/feature/navigational_aid/marker.rb +12 -15
- data/lib/aixm/feature/navigational_aid/ndb.rb +13 -16
- data/lib/aixm/feature/navigational_aid/tacan.rb +15 -17
- data/lib/aixm/feature/navigational_aid/vor.rb +16 -19
- data/lib/aixm/feature/navigational_aid.rb +7 -7
- data/lib/aixm/feature/obstacle.rb +20 -21
- data/lib/aixm/feature/obstacle_group.rb +19 -20
- data/lib/aixm/feature/organisation.rb +11 -12
- data/lib/aixm/feature/unit.rb +16 -18
- data/lib/aixm/feature.rb +26 -7
- data/lib/aixm/object.rb +1 -1
- data/lib/aixm/refinements.rb +57 -0
- data/lib/aixm/schedule/date.rb +13 -1
- data/lib/aixm/schedule/date_time.rb +56 -0
- data/lib/aixm/schedule/time.rb +5 -1
- data/lib/aixm/shortcuts.rb +8 -2
- data/lib/aixm/version.rb +1 -1
- data/lib/aixm.rb +5 -3
- data/schemas/ofmx/0.1/OFMX-Snapshot.xsd +6 -1
- data.tar.gz.sig +2 -3
- metadata +26 -38
- metadata.gz.sig +2 -3
- data/lib/aixm/association.rb +0 -378
- data/lib/aixm/memoize.rb +0 -105
data/lib/aixm/memoize.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
module AIXM
|
2
|
-
|
3
|
-
# Memoize the return value of a specific method across multiple instances for
|
4
|
-
# the duration of a block.
|
5
|
-
#
|
6
|
-
# The method signature is taken into account, therefore calls of the same
|
7
|
-
# method with different positional and/or keyword arguments are cached
|
8
|
-
# independently. On the other hand, when calling the method with a block,
|
9
|
-
# no memoization is performed at all.
|
10
|
-
#
|
11
|
-
# Nested memoization of the same method is allowed and won't reset the
|
12
|
-
# memoization cache.
|
13
|
-
#
|
14
|
-
# @example
|
15
|
-
# class Either
|
16
|
-
# include AIXM::Memoize
|
17
|
-
#
|
18
|
-
# def either(argument=nil, keyword: nil, &block)
|
19
|
-
# $entropy || argument || keyword || (block.call if block)
|
20
|
-
# end
|
21
|
-
# memoize :either
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# a, b, c = Either.new, Either.new, Either.new
|
25
|
-
#
|
26
|
-
# # No memoization before the block
|
27
|
-
# $entropy = nil
|
28
|
-
# a.either(1) # => 1
|
29
|
-
# b.either(keyword: 2) # => 2
|
30
|
-
# c.either { 3 } # => 3
|
31
|
-
# $entropy = :not_nil
|
32
|
-
# a.either(1) # => :not_nil
|
33
|
-
# b.either(keyword: 2) # => :not_nil
|
34
|
-
# c.either { 3 } # => :not_nil
|
35
|
-
#
|
36
|
-
# # Memoization inside the block
|
37
|
-
# AIXM::Memoize.method :either do
|
38
|
-
# $entropy = nil
|
39
|
-
# a.either(1) # => 1
|
40
|
-
# b.either(keyword: 2) # => 2
|
41
|
-
# c.either { 3 } # => 3
|
42
|
-
# $entropy = :not_nil
|
43
|
-
# a.either(1) # => 1 (memoized)
|
44
|
-
# b.either(keyword: 2) # => 2 (memoized)
|
45
|
-
# c.either { 3 } # => :not_nil (cannot be memoized)
|
46
|
-
# end
|
47
|
-
#
|
48
|
-
# # No memoization after the block
|
49
|
-
# $entropy = nil
|
50
|
-
# a.either(1) # => 1
|
51
|
-
# $entropy = :not_nil
|
52
|
-
# a.either(1) # => :not_nil
|
53
|
-
module Memoize
|
54
|
-
module ClassMethods
|
55
|
-
def memoize(method)
|
56
|
-
unmemoized_method = :"unmemoized_#{method}"
|
57
|
-
alias_method unmemoized_method, method
|
58
|
-
define_method method do |*args, **kargs, &block|
|
59
|
-
if block || !AIXM::Memoize.cache.has_key?(method)
|
60
|
-
send(unmemoized_method, *args, **kargs, &block)
|
61
|
-
else
|
62
|
-
cache = AIXM::Memoize.cache[method]
|
63
|
-
id = object_id.hash ^ args.hash ^ kargs.hash
|
64
|
-
if cache.has_key?(id)
|
65
|
-
cache[id]
|
66
|
-
else
|
67
|
-
cache[id] = send(unmemoized_method, *args, **kargs)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class << self
|
75
|
-
attr_reader :cache
|
76
|
-
|
77
|
-
def included(base)
|
78
|
-
base.extend(ClassMethods)
|
79
|
-
@cache = {}
|
80
|
-
end
|
81
|
-
|
82
|
-
def method(method, &block) # TODO: [ruby-3.1] use anonymous block "&" on this and next line
|
83
|
-
send(:"call_with#{:out if cached?(method)}_cache", method, &block)
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
def cached?(method)
|
89
|
-
cache.has_key?(method)
|
90
|
-
end
|
91
|
-
|
92
|
-
def call_without_cache(method)
|
93
|
-
yield
|
94
|
-
end
|
95
|
-
|
96
|
-
def call_with_cache(method)
|
97
|
-
cache[method] = {}
|
98
|
-
yield
|
99
|
-
ensure
|
100
|
-
cache.delete(method)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|